次のテンプレート クラスがあるとします。
template<typename T> class Wrap { /* ... */ };
変えることはできませ んWrap
。大事です。
から派生したクラスがあるとしWrap<T>
ます。例えば、
class NewInt : public Wrap<int> { /* ... */ };
class MyClass : public Wrap<myclass> { /* ... */ };
class Foo : public Wrap<Bar> { /* ... */ };
これらのクラスも変更できません。上記のすべてのクラスはサードパーティです。彼らは私のものではありません。
次のコンパイル時間が必要ですtype_traits
。
template<class T>
struct is_derived_from_Wrap {
static const bool value = /* */;
};
私が必要なものは何?
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);