I have a two levels template:
types
class Type{};
class TypeExt:public Type{};
1, Fist level:
//the type must be an inheritance of Type
template<typename T, typename std::enable_if<std::is_base_of<Type, T>::value>::type* = nullptr>
class FirstLevel{};
class FirstLevelSpecialization_1:public FirstLevel<Type>{};
class FirstLevelSpecialization_2:public FirstLevel<TypeExt>{};
2, Second Level
//the type must be an inheritance of FirstLevel
template<typename T, typename std::enable_if<std::is_base_of<FirstLevel, T>::value>::type* = nullptr>
class SecondLevel{};
class SecondLevelSpecialization: public SecondLevel<FirstLevelSpecialization_1>{};
The last line will give an error:
Invalid template arguments
I know how to solve this problem in Java,questions are:
1,Is this problem solvable in C++?
2,If yes,would you please give some tips to solve it?