Hello!
Do I have any way to simplify the following statements? (probably, using boost::enable_if
).
I have a simple class structure - Base
base class, Derived1
, Derived2
inherit from Base
.
I have the following code:
template <typename Y> struct translator_between<Base, Y> {
typedef some_translator<Base, Y> type;
};
template <typename Y> struct translator_between<Derived1, Y> {
typedef some_translator<Derived1, Y> type;
};
template <typename Y> struct translator_between<Derived2, Y> {
typedef some_translator<Derived2, Y> type;
};
I want to write the same statement using one template specialization of translator_between
.
An example (pseudocode) of what I want to be able to write:
template <typename Class, typename Y>
ONLY_INSTANTIATE_THIS_TEMPLATE_IF (Class is 'Base' or any derived from 'Base')
struct translator_between<Class, Y> {
typedef some_translator<Class, Y> type;
};
Any way to achieve this using boost::enable_if
and boost::is_base_of
?