Hi
I'd like to implement some kind if type traits myself, but I have to
support broken compilers (like visual studio) that do not support
Partial Specialization.
My first shot was something like this:
----8<---
typedef char IsPODForListArr ayTrue;
typedef struct {char bla[2];} IsPODForListArr ayFalse;
IsPODForListArr ayTrue IsPODForListArr ayDummy(int);
IsPODForListArr ayTrue IsPODForListArr ayDummy(long);
IsPODForListArr ayFalse IsPODForListArr ayDummy(...);
#define IsPODForListArr ay(x) (sizeof(IsPODFo rListArrayDummy (x)) ==
sizeof(IsPODFor ListArrayTrue))
-----8<----
This seems to work, BUT, the problem here is that I cant just pass a
typename to IsPodForListArr ay but rather have to pass something real.
eg. IsPodForListArr ay (int) <-- wont work
int foo; IsPodForListArr ay(foo) <-- works
This is not acceptable, since I do want to use this in places where i
can only use types (eg template parameters).
I do want to implement it myself, and not add any non std. libs.
Any ideas of what I could do ?
I somehow have to work around the need for partial specialization ..
with kind regards Philip
I'd like to implement some kind if type traits myself, but I have to
support broken compilers (like visual studio) that do not support
Partial Specialization.
My first shot was something like this:
----8<---
typedef char IsPODForListArr ayTrue;
typedef struct {char bla[2];} IsPODForListArr ayFalse;
IsPODForListArr ayTrue IsPODForListArr ayDummy(int);
IsPODForListArr ayTrue IsPODForListArr ayDummy(long);
IsPODForListArr ayFalse IsPODForListArr ayDummy(...);
#define IsPODForListArr ay(x) (sizeof(IsPODFo rListArrayDummy (x)) ==
sizeof(IsPODFor ListArrayTrue))
-----8<----
This seems to work, BUT, the problem here is that I cant just pass a
typename to IsPodForListArr ay but rather have to pass something real.
eg. IsPodForListArr ay (int) <-- wont work
int foo; IsPodForListArr ay(foo) <-- works
This is not acceptable, since I do want to use this in places where i
can only use types (eg template parameters).
I do want to implement it myself, and not add any non std. libs.
Any ideas of what I could do ?
I somehow have to work around the need for partial specialization ..
with kind regards Philip
Comment