I am guessing this is not possible, but I am really hoping it is. An example:
template<class T>
concept bool Dereferencable() { return requires(T t){ *t }; }
template<class T>
concept bool Incrementable() { return requires(T t){ ++t }; }
template<class T, ??? X, ??? Y>
concept bool And() { return X<T>() && Y<T>(); }
static_assert( And<int*, Dereferencable, Incrementable>() );
Is there a way to do something like this?
If not, is there a hack to achieve the same functionality?
Ultimately I'd like to use compound concepts as placeholder constraints.
Concepts can really only be used in limited ways (as of this writing). As a consequence, it is not possible to achieve what you want.
A workaround would be to associate to each concept a particular (meta)function in order to enable higher-order use:
// this is just one way of doing it...
template<typename Arg>
struct is_dereferencable_f {
static constexpr bool value = Dereferencable<Arg>;
};
// ...via template template parameters
template<typename Arg, template<typename> typename... Conjuncts>
concept bool SatisfiesAll = (... && Conjuncts<Arg>::value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With