The cppreference.com states that:
Concepts cannot recursively refer to themselves
But how can we define a concept that will represent an integer or a vector of integers, or a vector of vector of integers, etc.
I can have something this:
template < typename Type > concept bool IInt0 = std::is_integral_v<Type>;
template < typename Type > concept bool IInt1 = IInt0<Type> || requires(Type tt) { {*std::begin(tt)} -> IInt0; };
template < typename Type > concept bool IInt2 = IInt1<Type> || requires(Type tt) { {*std::begin(tt)} -> IInt1; };
static_assert(IInt2<int>);
static_assert(IInt2<std::vector<int>>);
static_assert(IInt2<std::vector<std::vector<int>>>);
But I want to have something like IIntX
that will mean IIntN for any N.
Is it possible?
See Question&Answers more detail:os