Jak uzyskać wywołanie konstruktora kopiowania przez konstruktor zmienny?
W poniższym kodzie konstruktor variadic jest wywoływany dwukrotnie. Jak w razie potrzeby mogę wywołać konstruktor kopiowania zamiast wersji z pojedynczym argumentem konstruktora zmiennoprzecinkowego?
#include <iostream>
struct Foo
{
Foo(const Foo &)
{
std::cout << "copy constructor\n";
}
template<typename... Args>
Foo(Args&&... args)
{
std::cout << "variadic constructor\n";
}
std::string message;
};
int main()
{
Foo f1;
Foo f2(f1); // this calls the variadic constructor, but I want the copy constructor.
}