concepts: add tuplelike concept
This commit is contained in:
parent
455b3b973f
commit
84cbbbd049
12
concepts.hpp
12
concepts.hpp
@ -228,6 +228,8 @@ namespace cruft::concepts {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Some handy non-standard concepts
|
// Some handy non-standard concepts
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
namespace cruft::concepts {
|
namespace cruft::concepts {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept arithmetic = std::is_arithmetic_v<T>;
|
concept arithmetic = std::is_arithmetic_v<T>;
|
||||||
@ -257,4 +259,14 @@ namespace cruft::concepts {
|
|||||||
{ std::begin (t) } -> legacy_iterator;
|
{ std::begin (t) } -> legacy_iterator;
|
||||||
{ std::end (t) } -> legacy_iterator;
|
{ std::end (t) } -> legacy_iterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// A class that supports tuple manipulators.
|
||||||
|
template <typename T>
|
||||||
|
concept tuple = requires (T a, T b)
|
||||||
|
{
|
||||||
|
{ std::tuple_element<0,T> {} };
|
||||||
|
{ std::tuple_size<T>::value } -> convertible_to<std::size_t>;
|
||||||
|
{ std::tuple_cat (a, b) };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user