Let's consider such class hierarchy
template<typename T>
struct Base
{
template<typename...U>
constexpr static bool SOME_TRAIT = std::is_constructible_v<T,U...>;
};
template<typename T>
struct Derived : Base<T>
{
//some usage of SOME_TRAIT
};
To use it in Dervied I have to use sth like:
template<typename...U>
constexpr static bool SOME_TRAIT = Base<T>::template SOME_TRAIT<U...>;
Which can be noisy. Is there something like using declaration for member functions, but usable for SOME_TRAIT?
Nope. Or, rather, you've already found the best way to do it.
The problem is, the parser needs to have the shape of SOME_TRAIT explained to it. using SOME_TRAIT wouldn't give it any more information about whether the < and > in SOME_TRAIT<foo> should be interpreted as operators or delimiters. The language standard requires that that be done at the point of definition of Derived, rather than waiting until Derived is actually specialized and used, and so it can't assume that SOME_TRAIT will always be a variable template (because Base might be given a specialization later on). What you're giving it there, other than the bool and naming U, is the minimum amount of information the parser needs to do its job.
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