I have a code snipped including a variadic mixin crtp of some sorts and a few related questions. Do I understand correctly that in the following code, the second constructor is merely passing copies of instances of those classes which were used to instantiate X to the constructors of those very same classes?
template<class DerivedT>
struct CuriousBase{};
template<template<typename> typename... Features>
struct X : Features<X<Features...>> ... {
X() = default;
X(Features<X<Features...>> ...f) : Features<X<Features...>>(f)... {}
};
int main(){
auto x = X<CuriousBase>{};
}
what are use cases for such a behaviour and what is the difference between this sample and the following snippet?
template<class DerivedT>
struct CuriousBase{};
template<template<typename> typename... Features>
struct X : Features<X<Features...>> ... {
X() = default;
X(Features<X> ...f) : Features<X>(f)... {}
};
int main(){
auto x = X<CuriousBase>{};
}
Both do compile but I thought, that one has to specify explicitly that X is itself a variadic class template but that does not seem to be necessary...
help is greatly appreciated
X
is a injected class name, so indeedX
andX<Features...>
are equivalent inside the class.