-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Expert C++ - Second Edition
By :
Iterators were the first to fully use concepts after they were introduced. Iterators and their categories are now considered legacy because, starting from C++20, we use iterator concepts such as readable (which specifies that the type is readable by applying the * operator) and writable (which specifies that a value can be written to an object referenced by the iterator). Let’s look at how incrementable is defined in the <iterator> header, as promised:
template <typename T>concept incrementable = std::regular<T> && std::weakly_incrementable<T> && requires (T t) { {t++} -> std::same_as<T>; };
Therefore, the incrementable concept requires the type to be std::regular. This means it should be constructible by default and have a copy constructor and operator==(). Besides that, the incrementable concept requires the type to be weakly_incrementable, which means the type supports pre- and post-increment...