名稱空間
變體
操作

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

來自 cppreference.com
 
 
範圍庫 (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));
}

[編輯] 參閱

返回底層(適配)檢視的副本
(公共成員函式) [編輯]