std::ranges::take_while_view<V,Pred>::pred
来自 cppreference.cn
< cpp | ranges | take_while_view
constexpr const Pred& pred() const; |
(C++20 起) | |
返回对存储的谓词 pred_
的引用。
如果 *this 不存储谓词(例如,在向 *this 赋值时抛出异常,而该赋值通过复制构造或移动构造一个 Pred
),则行为未定义。
目录 |
[编辑] 参数
(无)
[编辑] 返回值
对存储的谓词的引用。
[编辑] 示例
运行此代码
#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)); }
[编辑] 参阅
返回底层(适配)视图的副本 (公共成员函数) |