The base components of my hobby library has to work with C++98 and C++11 compilers. To learn and to enjoy myself I created the C++98 implementations of several type support functionality (like enable_if
, conditional
, is_same
, is_integral
etc. ...) in order to use them when there is no C++11 support.
However while I was implementing is_constructible
I got stuck. Is there any kind of template magic (some kind of SFINAE) with which I can implement it without C++11 support (declval
)?
Of course there is no variadic template support in C++03, so I will specialise the implementation till some depth. The main question is if there is a technique that can decide whether T is constructible from the given types or not.
I think Danh's idea was great! With a minor modification we can eliminate the operator new. (I have a C++98 enable_if and remove_reference implementation). The mentioned int*, void* case works with this implementation too. No operator new required. Only the old g++ support remains...
It's possible:
You can expand the 2 parameters version for 3, 4, 5, ... parameters further more.
Live Demo
This works with g++ 4.4.7
It doesn't work with g++ 4.3.6