Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/iterator/incrementable"

From cppreference.com
< cpp‎ | iterator
m (removed unnessisary "(1)")
(I just found a better definition of this concept elsewhere on cppreference...)
Line 4: Line 4:
 
{{dcl header|iterator|since=c++20}}
 
{{dcl header|iterator|since=c++20}}
 
{{dcl | since=c++20 | 1=
 
{{dcl | since=c++20 | 1=
template < class T >
+
template<class I>
concept incrementable = requires std::weakly_incrementable<T> &&  
+
    concept incrementable =
                                std::equality_comparable<T>;
+
        regular<I> &&
 +
        weakly_incrementable<I> &&
 +
        requires(I i) {
 +
            { i++ } -> same_as<I>;
 +
        };
 
}}
 
}}
 
{{dcl end}}
 
{{dcl end}}

Revision as of 11:20, 5 October 2019

 
 
Iterator library
Iterator concepts
Iterator primitives
Algorithm concepts and utilities
Indirect callable concepts
Common algorithm requirements
(C++20)
(C++20)
(C++20)
Utilities
(C++20)
Iterator adaptors
Range access
(C++11)(C++14)
(C++14)(C++14)  
(C++11)(C++14)
(C++14)(C++14)  
(C++17)(C++20)
(C++17)
(C++17)
 
Defined in header <iterator>
template<class I>

    concept incrementable =
        regular<I> &&
        weakly_incrementable<I> &&
        requires(I i) {
            { i++ } -> same_as<I>;

        };
(since C++20)

The concept incrementable<T> is satisfied if and only if T is weakly_incrementable, equality preserving, and is equality_comparable.

See also

specifies that a semiregular type can be incremented with pre- and post-increment operators
(concept) [edit]
(C++20)
specifies that a type is the same as another type
(concept) [edit]