Support Class Library
A set of tools providing classes and utility
Iterator.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <scl/macros.h>
4 #include <scl/concepts/require.h>
10 #include <scl/tools/meta/exists.h>
12 #include <iterator>
13 
14 namespace scl{
15  namespace concepts{
21  template <class T>
22  struct Iterator{
23  constexpr operator bool() const{
25  Copyable<T>{}
26  && Destructible<T>{}
27 //#ifdef SCL_CPP17
28  && Swappable<T>{}
29 //#endif
30 #define SCL_TRAIT(type) typename std::iterator_traits<T>::type
31  && META::exists<SCL_TRAIT(value_type)>()
32  && META::exists<SCL_TRAIT(difference_type)>()
33  && META::exists<SCL_TRAIT(reference)>()
34  && META::exists<SCL_TRAIT(pointer)>()
35  && META::exists<SCL_TRAIT(iterator_category)>()
36 #undef SCL_TRAIT
37 #define SCL_LVALUE std::declval<T&>()
38  && META::exists<decltype(*SCL_LVALUE)>()
39  && META::is_convertible<decltype(++SCL_LVALUE), T&>()
40 #undef SCL_LVALUE
41  >();
42  }
43  };
44  }
45 }
constexpr bool constexpr_assert()
Global namespace of the SCL.
Definition: alias.hpp:3
Destructible concept, a type T is destructible if it defines a destructor that won&#39;t throw...
Definition: Destructible.h:12
Swappable concept, a type is swappable if it defines swapping mecanisms.
Definition: Swappable.h:13
constexpr bool exists()
Determines whether or not the given type is well-formed.
Definition: exists.h:23
constexpr bool is_convertible()
An handy function for the result of std::is_convertible.
#define SCL_LVALUE
#define SCL_TRAIT(type)
Iterator concept, a type is an iterator if it is copyable, destructible, swappable, has well-defined iterator_traits and can be incremented and dereferenced.
Definition: Iterator.h:22
Copyable concept, a type is copyable if it is both copy constructible and copy assignable.
Definition: Copyable.h:16