So, I'd like to do some advanced type-level hackery for which I would really like to be able to write a concept that requires a type to have a constexpr int
value associated with it, which I can use later in the same concept as the integer std::array
template parameter.
It's possible to write
template<typename T>
concept bool HasCount = requires {
typename T::count;
};
but this is not what I want; I would like T::count
to be a static constexpr int
. However, the code (not even including the needed constexpr
)
template<typename T>
concept bool HasCount = requires {
int T::count;
};
does not compile with "error: expected primary-expression before 'int'" on GCC 7.3.0.
Another failed attempt: it's possible to write this, which would require static int T::count()
:
template<typename T>
concept bool HasCount = requires {
{T::count()} -> int;
};
but not this, which is what I want:
template<typename T>
concept bool HasCount = requires {
{T::count()} -> constexpr int;
{T::count() constexpr} -> int; // or this
{constexpr T::count()} -> int; // or this (please forgive me for fuzzing GCC instead of reading the manual, unlike perl C++ is not an empirical science)
};
So, I'd like to know if it's in any way possible to require a concept expression to be constexpr-qualified, or if not if there's a reason why it can't be possible, or if it's just not included in the specification.