Suppose I have a function template and want to declare a value-initialized object:
template<typename T>
void foo() {
// declare and default-initialize 'x' of type 'T'
}
Can I do it?
T x;
fails for primitive types because it leaves them uninitialized,T x();
fails because of the most vexing parseT x = T();
requires a copy constructor and doesn't require the compiler elide the copyT x{};
fails because we're not using C++11.
I'm hoping I'm being an idiot and overlooking something obvious, but I'm not seeing the answer.