If I can a parameter pack for the constructor arguments when I create a new object and I don't provide any constructor arguments then the result will be: new T(); which will value-initialize the object if it doesn't have a user-provided constructor. How do I stop this from happening?
template <typename T>
struct Foo
{
template <typename ... ConstructorArgs>
static void create(ConstructorArgs ... constructorArgs)
{
T* ptr = new T(constructorArgs ...);
T* ptr2 = new T;
std::cout << *ptr; // It seems it value-initialized (zero-initialized) it
std::cout << *ptr2; // Default initialized it
}
};
int main()
{
Foo<int>::create();
}