concepts: add tuplelike concept

This commit is contained in:
Danny Robson 2020-02-24 14:38:42 +11:00
parent 455b3b973f
commit 84cbbbd049

View File

@ -228,6 +228,8 @@ namespace cruft::concepts {
///////////////////////////////////////////////////////////////////////////////
// Some handy non-standard concepts
#include <tuple>
namespace cruft::concepts {
template <typename T>
concept arithmetic = std::is_arithmetic_v<T>;
@ -257,4 +259,14 @@ namespace cruft::concepts {
{ std::begin (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) };
};
}