std::ranges::drop_while_view<V,Pred>::pred
來自 cppreference.com
< cpp | ranges | drop while view
constexpr const Pred& pred() const; |
(C++20 起) | |
返回對儲存的謂詞的引用。
如果 *this 未儲存謂詞(例如,在對 *this 的賦值中丟擲異常,而該賦值複製構造或移動構造了一個 Pred
),則行為未定義。
[編輯] 引數
(無)
[編輯] 返回值
對儲存的謂詞 pred_
的引用。
[編輯] 示例
執行此程式碼
#include <array> #include <iomanip> #include <iostream> #include <ranges> int main() { constexpr std::array data{0, -1, -2, 3, 1, 4, 1, 5}; auto view = std::ranges::drop_while_view { data, [](int x) { return x <= 0; } }; std::cout << std::boolalpha; for (int x : data) std::cout << "predicate(" << std::setw(2) << x << ") : " << view.pred()(x) << '\n'; }
輸出
predicate( 0) : true predicate(-1) : true predicate(-2) : true predicate( 3) : false predicate( 1) : false predicate( 4) : false predicate( 1) : false predicate( 5) : false