I have a variadic template function that works except if I call it with an argument of the same type as T
.
template <typename T, typename... Arg>
std::shared_ptr<T> make_shared(Arg&&... arg)
{
return std::shared_ptr<T>(new T(std::forward<Arg>(arg)...));
}
Working call:
auto sahredStr = make_shared<std::string>("fubar");
Ambigous call:
std::string str = "fubar";
auto sharedStr = make_shared<std::string>(str);
I would like to understand what is wrong with the second call.