I want to pass Derived
class as a template parameter Base<T>
class.
When my Derived
class is a template and it is very long, my code has minor maintainability and readability problem, e.g.
template<class Derived>class Base{ //library : don't modify me
};
template<template<class>class T1,class T2,class T3>class Derived : //user class
public Base<Derived<T1,T2,T3>>{
};
I have some cases that Derived has a lot of template and I have to re-type/copy-paste it several times :-
template<template<class>class T1,class T2,class T3>class HyperDatabase : //user class
public IndexManager<HyperDatabase<T1,T2,T3>>,
public AwesomeHash<HyperDatabase<T1,T2,T3>,BitShifter>,
public Allocator<AlloDefault,HyperDatabase<T1,T2,T3>> { // etc...
};
Question
Is there a way to make it more concise?
I dream for something like :-
template<template<class>class T1,class T2,class T3>class Derived : //user class
public Base<Derived>{
};
OR
template<template<class>class T1,class T2,class T3>class Derived : //user class
public Base<MEEEEEEE>{
};
My poor solutions
Use macro
#define MEEEEEEE Derived<T1,T2,T3>
.Double inheritance : it is too awkward :-
template<class T>class Base2: public Base<T>{};//user class template<template<class>class T1,class T2,class T3>class Derived : //user class public Base2<Derived<T1,T2,T3>>{ };