Namespaces
Variants

std::ranges::take_while_view<V,Pred>:: pred

From cppreference.net
Ranges library
Range adaptors
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));
}

参见

返回底层(适配的)视图的副本
(公开成员函数)