P
Philip Lawatsch
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 IsPODForListArrayTrue;
typedef struct {char bla[2];} IsPODForListArrayFalse;
IsPODForListArrayTrue IsPODForListArrayDummy(int);
IsPODForListArrayTrue IsPODForListArrayDummy(long);
IsPODForListArrayFalse IsPODForListArrayDummy(...);
#define IsPODForListArray(x) (sizeof(IsPODForListArrayDummy(x)) ==
sizeof(IsPODForListArrayTrue))
-----8<----
This seems to work, BUT, the problem here is that I cant just pass a
typename to IsPodForListArray but rather have to pass something real.
eg. IsPodForListArray (int) <-- wont work
int foo; IsPodForListArray(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 IsPODForListArrayTrue;
typedef struct {char bla[2];} IsPODForListArrayFalse;
IsPODForListArrayTrue IsPODForListArrayDummy(int);
IsPODForListArrayTrue IsPODForListArrayDummy(long);
IsPODForListArrayFalse IsPODForListArrayDummy(...);
#define IsPODForListArray(x) (sizeof(IsPODForListArrayDummy(x)) ==
sizeof(IsPODForListArrayTrue))
-----8<----
This seems to work, BUT, the problem here is that I cant just pass a
typename to IsPodForListArray but rather have to pass something real.
eg. IsPodForListArray (int) <-- wont work
int foo; IsPodForListArray(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