Suppose we have the following template class
template<typename T> class Wrap { /* ... */ };
We can not change Wrap
. It is important.
Let there are classes derived from Wrap<T>
. For example,
class NewInt : public Wrap<int> { /* ... */ };
class MyClass : public Wrap<myclass> { /* ... */ };
class Foo : public Wrap<Bar> { /* ... */ };
We can not change these classes too. All classes above is 3rd party. They are not mine.
I need the following compile time type_traits
:
template<class T>
struct is_derived_from_Wrap {
static const bool value = /* */;
};
What do I need?
assert(is_derived_from_Wrap<Int>::value == true); // Indeed I need static assert
assert(is_derived_from_Wrap<MyClass>::value == true);
assert(is_derived_from_Wrap<char>::value == false);
struct X {};
assert(is_derived_from_Wrap<X>::value == false);