I know that a std::ref(object) creates a std::reference_wrapper(object), and that std::reference_wrapper has a non-explicit type conversion operator member function
operator T&() const
and I know that this influences how I use it when template parameter deduction comes into play: so in Print below, the type T of the argument is deduced as std::reference_wrapper if I call it with,say, std::ref("hello")
template <class T>
void Print(T t)
{
std::cout << t << std::end;
}
Why doesn't this line compile?
std::string s = "hello";
std::cout << std::reference_wrapper<std::string>(s) << std::endl;
the instantiated specialization should have a
operator std::string&() const
type conversion function, so why can't I use a reference wrapper like this?