Say I have a concept:
template < typename Group > concept bool GGroup =
requires() { typename Group::Inner; };
How can I retrieve the type Inner
when using the concept in the short form?
void doSomething(const GGroup& group)
{
// an ugly alternative
using Inner = typename std::decay_t<decltype(group)>::Inner;
//// could be something like:
// using Inner = GGroup::Inner;
// or
// using Inner = underlyingtype(GGroup)::Inner;
}
The built-in downside of the short-form of Concepts TS is that you can't just name the typename of a conceptualized parameter. You have to use decltype
to get it.
So you have a tradeoff: you can either avoid having an explicit template
declaration at the expense of more decltype
in your actual code, or you can avoid having decltype
at the expense of an explicit template declaration.
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