05/01/08 00:55:07
これでどうだろう。>>184 と組み合わせてみた。
template<class T> struct wrap{ typedef T type; };
template<class T> struct wrap<void (T)>{ typedef T type; };
#define TYPE(x) wrap<void x>::type
template< bool >struct ExistsBool{};
template<>struct ExistsBool< true >{ enum { _true }; };
#defineTYPEDEF( type, alias ) \
__if_exists( __template__::_true ){ typedef typename TYPE((typename type)) alias; } \
__if_not_exists( __template__::_true ){ typedef TYPE((type)) alias; } \
#defineCLASS( __Class ) \
typedef __Classself; \
typedef ExistsBool< false >__template__; \
#defineTEMPLATE( __Class ) \
typedef __Classself; \
typedef ExistsBool< true >__template__; \
#define$,