std::ranges::take_while_view<V,Pred>::pred
来自cppreference.com
< cpp | ranges | take while view
constexpr const Pred& pred() const; |
(C++20 起) | |
返回到存储的谓词 pred_
的引用。
若 *this 不存储谓词(例如在复制构造或移动构造 Pred
的对 *this 的赋值时抛出异常),则行为未定义。
参数
(无)
返回值
到存储的谓词的引用。
示例
运行此代码
#include <ranges> int main() { static constexpr int a[]{1, 2, 3, 4, 5}; constexpr auto v = a | std::views::take_while([](int x){ return x < 4; }); const auto pred = v.pred(); static_assert(pred(3)); }
参阅
返回底层(适配的)视图的副本 (公开成员函数) |