std::ranges::common_range
來自 cppreference.com
| 定義於標頭檔案 <ranges> |
||
| template< class T > concept common_range = |
(C++20 起) | |
common_range 概念是 range 的一個細化,其 std::ranges::begin() 和 std::ranges::end() 返回相同的型別(例如,所有標準庫容器)。
[編輯] 示例
執行此程式碼
#include <ranges> struct A { char* begin(); char* end(); }; static_assert( std::ranges::common_range<A> ); struct B { char* begin(); bool end(); }; // not a common_range: begin/end have different types static_assert( not std::ranges::common_range<B> ); struct C { char* begin(); }; // not a common_range, not even a range: has no end() static_assert( not std::ranges::common_range<C> ); int main() {}
[編輯] 參閱
將 view 轉換為 common_range(類模板) (範圍介面卡物件) |