Remove template type from templated class

Viewed 122

I have this structure:

template <typename T>
using AllSettings = std::variant<
    A<T>,
    B<T>,
    C<T>,
    D<T>
>;

template typename<T>
void Foo() {
    using SettingClassT = std::variant_alternative_t<0, AllSettings<T>>;

    //....
}

is it possible to obtain base class without <T> from the SettingClassT? Something like this:

template <typename T>
using SettingClassBase = ... somehow remove T from SettingClassT

Because I need to call other template method that expects base type and T type separatelly.

template <template<class> class Base, typename T>
void Bar() { }

so I can call:

Bar<SettingClassBase, T>();
1 Answers

Not sure about what do you exactly want but... seems to me that you're looking for a template struct as getTemplatePar

template <typename>
struct getTemplatePar;

template <template <typename> class C, typename T>
struct getTemplatePar<C<T>>
 { 
   template <typename U>
   using baseType = C<U>;
 };

so you can write Foo() as follows (thanks to Evg and cigien for the template correction):

template <typename T>
void Foo()
 {
   using SettingClassT = std::variant_alternative_t<0, AllSettings<T>>;

   Bar<getTemplatePar<SettingClassT>::template baseType, T>();
 }
Related