std::iter_value_t, std::iter_reference_t, std::iter_const_reference_t, std::iter_difference_t, std::iter_rvalue_reference_t, std::iter_common_reference_t (original) (raw)

Defined in header
template< class T > using iter_value_t = /* see below */; (1) (since C++20)
template< /*dereferenceable*/ T > using iter_reference_t = decltype(*std::declval<T&>()); (2) (since C++20)
template< std::indirectly_readable T > using iter_const_reference_t = std::common_reference_t<const std::iter_value_t<T>&&, std::iter_reference_t<T>>; (3) (since C++23)
template< class T > using iter_difference_t = /* see below */; (4) (since C++20)
template< /*dereferenceable*/ T> requires /* see below */ using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<T&>())); (5) (since C++20)
template< std::indirectly_readable T > using iter_common_reference_t = std::common_reference_t<std::iter_reference_t<T>, /*indirect-value-t*/<T>>; (6) (since C++20)
Helper templates
template< class T >concept /*dereferenceable*/ = /* see below */; (7) (exposition only*)
template< std::indirectly_readable T > using /*indirect-value-t*/ = /* see below */; (8) (exposition only*)

Compute the associated types of an iterator.

  1. Computes the reference type of T.

  2. Computes the const reference type of T.

  3. Computes the rvalue reference type of T. The constraint on this alias template is satisfied if and only if the expression ranges::iter_move(std::declval<T&>()) is valid and has a referenceable type.

  4. Computes the common reference type of T. This is the common reference type between its reference type and an lvalue reference to its value type.

  5. The exposition-only concept _dereferenceable_ is satisfied if and only if the expression *std::declval<T&>() is valid and has a referenceable type.

  6. The exposition-only alias template _indirect-value-t_ denotes the following:

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
P2609R3 C++20 std::iter_common_reference_t was defined in termsof std::iter_value_t<T>& which incorrectly handledstd::projected types that project into rvalue reference types defined in terms of/*indirect-value-t*/<T>to handle such cases

[edit] See also

indirectly_readable(C++20) specifies that a type is indirectly readable by applying operator * (concept) [edit]
weakly_incrementable(C++20) specifies that a semiregular type can be incremented with pre- and post-increment operators (concept) [edit]
indirectly_readable_traits(C++20) computes the value type of an indirectly_readable type (class template) [edit]
incrementable_traits(C++20) computes the difference type of a weakly_incrementable type (class template) [edit]
iterator_traits provides uniform interface to the properties of an iterator (class template) [edit]
ranges::iterator_tranges::const_iterator_tranges::sentinel_tranges::const_sentinel_t(C++20)(C++23)(C++20)(C++23) obtains iterator and sentinel types of a range(alias template)[edit]
ranges::range_reference_tranges::range_const_reference_tranges::range_rvalue_reference_tranges::range_common_reference_t(C++20)(C++23)(C++20)(C++20) obtains reference types of a range(alias template)[edit]
ranges::range_difference_tranges::range_size_tranges::range_value_t(C++20)(C++20)(C++20) obtains size, difference, and value types of a range(alias template)[edit]