concepts: add legacy_input_iterator and legacy_iterator
This commit is contained in:
parent
c001502aa2
commit
706e77f44a
51
concepts.hpp
51
concepts.hpp
@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
|
||||
@ -170,6 +171,56 @@ namespace cruft::concepts {
|
||||
{ a.max_size () } -> same_as<typename T::size_type>;
|
||||
{ a.empty () } -> boolean;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
concept move_assignable =
|
||||
requires (T a, T b)
|
||||
{
|
||||
{ a = std::move (b) } -> same_as<T&>;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
concept copy_assignable =
|
||||
move_assignable<T> &&
|
||||
requires (T a, T b)
|
||||
{
|
||||
{ a = b } -> same_as<T&>;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
concept legacy_iterator =
|
||||
copy_constructible<T> &&
|
||||
copy_assignable<T> &&
|
||||
destructible<T> &&
|
||||
swappable<T> &&
|
||||
requires (T t)
|
||||
{
|
||||
typename std::iterator_traits<T>::value_type;
|
||||
typename std::iterator_traits<T>::difference_type;
|
||||
typename std::iterator_traits<T>::reference;
|
||||
typename std::iterator_traits<T>::pointer;
|
||||
typename std::iterator_traits<T>::iterator_category;
|
||||
|
||||
{ *t };
|
||||
{ ++t } -> same_as<T&>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept legacy_input_iterator =
|
||||
legacy_iterator<T> &&
|
||||
equality_comparable<T> &&
|
||||
requires (T a, T b)
|
||||
{
|
||||
typename std::iterator_traits<T>::reference;
|
||||
typename std::iterator_traits<T>::value_type;
|
||||
{ a != b } -> boolean;
|
||||
|
||||
{ ++a } -> same_as<T&>;
|
||||
{ a++ };
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user