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)); }
[编辑] 参见
返回底层(已适配)视图的副本 (公共成员函数) |