concepts: add the supports_iterator_traits concept
This commit is contained in:
parent
2401cd60cf
commit
30f2db920c
17
concepts.hpp
17
concepts.hpp
@ -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>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user