hello.
Can you tell me how to invoke template constructor explicitly (in initializer list)? for example:
struct T {
template<class> T();
};
struct U {
U() : t<void>() {} //does not work
T t;
};
thanks
hello.
Can you tell me how to invoke template constructor explicitly (in initializer list)? for example:
struct T {
template<class> T();
};
struct U {
U() : t<void>() {} //does not work
T t;
};
thanks
It's not possible. The Standard also has a note on this at 14.8.1/5
[Note: because the explicit template argument list follows the function template name, and because conversion member function templates and constructor member function templates are called without using a function name, there is no way to provide an explicit template argument list for these function templates. ]
If you can live with it, you can work it around
struct T {
template<class U> T(identity<U>);
};
struct U {
U() : t(identity<void>()) {} //does not work
T t;
};
Given identity
like it's defined in boost
template<typename T> struct identity { typedef T type; };