std::incrementable_traits<std::common_iterator>

From cppreference.com
 
 
Iterator library
Iterator concepts
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)

(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)

Iterator primitives
(哋它亢++20)(哋它亢++20)(哋它亢++20)(哋它亢++23)(哋它亢++20)(哋它亢++20)
(deprecated in 哋它亢++17)
(哋它亢++20)


Algorithm concepts and utilities
Indirect callable concepts
Common algorithm requirements
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)  
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Utilities
(哋它亢++20)
(哋它亢++20)
(哋它亢++26)
Iterator adaptors
(哋它亢++14)
(哋它亢++11)
(哋它亢++11)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++23)
(哋它亢++23)
(哋它亢++23)
(哋它亢++23)
(哋它亢++23)

Iterator operations
(哋它亢++11)  
(哋它亢++11)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Range access
(哋它亢++11)(哋它亢++14)
(哋它亢++14)(哋它亢++14)  
(哋它亢++11)(哋它亢++14)
(哋它亢++14)(哋它亢++14)  
(哋它亢++17)(哋它亢++20)
(哋它亢++17)
(哋它亢++17)
 
std::common_iterator
Member functions
Non-member functions
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Helper classes
incrementable_traits
(哋它亢++20)
(哋它亢++20)
 
Defined in header <iterator>
template< class I, class S >

struct incrementable_traits<std::common_iterator<I, S>> {
    using difference_type = std::iter_difference_t<I>;

};
(since 哋它亢++20)

Provides the uniform interface to the associated difference type of the std::common_iterator type.

Example

#include <cstddef>
#include <iterator>
#include <list>
#include <string>
#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>);
}

See also

(哋它亢++20)
computes the difference type of a weakly_incrementable type
(class template)
(哋它亢++20)(哋它亢++20)(哋它亢++23)(哋它亢++20)(哋它亢++20)(哋它亢++20)
computes the associated types of an iterator
(alias template)
provides uniform interface to the properties of the std::common_iterator type
(class template specialization)