0

I have a following class:

template<typename T>
class Foo
{
public:
    typedef T value_type;
    operator value_type const& () const { return _val; }

private:
    value_type _val;
}

It's working with std::ostream when T is float, int etc. But for std::string I have to do something like that:

std::cout << f.operator const std::string &();

So my question is why? I can do std::cout << f for Foo<int> but not for Foo<std::string>?;

Quest
  • 2,628
  • 1
  • 19
  • 41

0 Answers0