concepts: add the supports_iterator_traits concept

This commit is contained in:
Danny Robson 2020-02-27 12:21:37 +11:00
parent 2401cd60cf
commit 30f2db920c

View File

@ -251,6 +251,23 @@ namespace cruft::concepts {
#include <tuple>
namespace cruft::concepts {
/// Tests if the type has all typedefs required for use with
/// std::iterator_traits.
template <typename T>
concept supports_iterator_traits = requires
{
typename T::difference_type;
typename T::value_type;
typename T::reference;
typename T::iterator_category;
// C++20 defines `pointer` as void if it's not present.
#if __cplusplus <= 201703L
typename T::pointer;
#endif
};
template <typename T>
concept arithmetic = std::is_arithmetic_v<T>;