# std::incrementable_traits<std::common_iterator>

< cpp‎ | iterator‎ | common iterator

定义于头文件 `<iterator>` |  |
template< class I, class S > struct incrementable_traits<std::common_iterator<I, S>> { using difference_type = std::iter_difference_t<I>; }; |  | (C++20 起)

对提供访问 std::common_iterator 类型的差类型提供统一接口。

### 示例

    #include <list>
    #include <string>
    #include <cstddef>
    #include <iterator>
    #include <type_traits>

    int main()
    {
        using CI = std::common_iterator<
                        std::counted_iterator<int*>,
                        std::default_sentinel_t
                        >;
        using CL = std::common_iterator<
                        std::counted_iterator<std::list<std::string>::iterator>,
                        std::default_sentinel_t
                        >;
        CL cl { std::default_sentinel };
        static_assert(
            std::same_as<std::incrementable_traits<CI>::difference_type, std::ptrdiff_t> &&
            std::same_as<std::incrementable_traits<CL>::difference_type, std::ptrdiff_t> &&
            std::same_as<std::incrementable_traits<decltype(cl)>::difference_type, std::ptrdiff_t>
        );
    }

### 参阅

incrementable_traits (C++20) | 计算 `weakly_incrementable` 类型的差类型 (类模板)
iter_value_t iter_reference_t iter_difference_t iter_rvalue_reference_t iter_common_reference_t (C++20)(C++20)(C++20)(C++20)(C++20) | 计算迭代器的关联类型 (别名模板)
std::iterator_traits<std::common_iterator> (C++20) | 对 std::counted_iterator 类型的属性提供均一的接口 (类模板特化)