std::incrementable_traits
來自 cppreference.com
< cpp | 迭代器 (iterator)
定義於標頭檔案 <iterator> |
||
template< class I > struct incrementable_traits {}; |
(1) | (C++20 起) |
template< class T > requires std::is_object_v<T> |
(2) | (C++20 起) |
template< class T > struct incrementable_traits<const T> |
(3) | (C++20 起) |
template< class T > requires requires { typename T::difference_type; } |
(4) | (C++20 起) |
template< class T > requires (!requires { typename T::difference_type; }) && |
(5) | (C++20 起) |
計算型別 I
的關聯差值型別(如果存在)。程式可以為程式定義型別特化 incrementable_traits
。
1) 主模板是一個空結構體。
2) 指標的特化。
提供一個成員型別
difference_type
,與 std::ptrdiff_t 相同。3) const 限定型別的特化。
4) 為定義公共且可訪問成員型別
difference_type
的型別進行特化。 提供一個成員型別
difference_type
,與 T::difference_type
相同。5) 為未定義公共且可訪問成員型別
difference_type
但支援減法運算的型別進行特化。 提供一個成員型別
difference_type
,與 std::make_signed_t<decltype(std::declval<T>() - std::declval<T>())> 相同。隱式表示式變體規則(見下文)適用於表示式 a - b。[edit] 隱式表示式變體
使用對某個常量左值運算元不進行修改的表示式的 requires 表示式 也需要隱式表示式變體。
[edit] 示例
本節不完整 原因:無示例 |
[edit] 參閱
(C++20) |
指定一個semiregular 型別可以使用前置和後置增量運算子進行增量操作(concept) |
(C++20)(C++20)(C++23)(C++20)(C++20)(C++20) |
計算迭代器的關聯型別 (alias template) |
提供迭代器屬性的統一介面 (class template) |