, typename
, Nawaz.
, : " B<T>::type*
. , B<T>::type
T
T
. :
class MyClass1 {};
typedef typename B<MyClass>::type MyClass2;
X<MyClass*> obj1;
X<MyClass2*> obj2;
(*)
MyClass2, MyClass1
. , obj1
obj2
. , X
?
X
, , , (*)
(, , obj2
). obj1
X
, (*)
.
, , - B<T>::type
, . , , , typedef .
, , .
,
I believe that your problem can be attacked by creating a class of attributes for explicitly marking types that must be handled in a special way. Something like that:
template <bool v>
struct boolean_value {
static const bool value=v;
};
template <typename T>
struct is_my_interesting_type : public boolean_value<false> {};
class MyClass {
...
};
template <>
struct is_my_interesting_type<MyClass> : public boolean_value<true> {};
template <typename T, bool special>
class InternalX {
...
};
template <typename T>
class InternalX<T,true> {
...
};
template <typename T>
class X : public InternalX<T,is_my_interesting_type<T>::value> {};
In addition, you may be wondering how this is done in the boost library, in particular Boost.Type_Traits
source
share