title: User-defined cast to string in C++ (like __repr__ in Python)
body: <p>How do I make something like user-defined <code>__repr__</code> in Python?</p>
  
  <p>Let's say I have an <code>object1</code> of <code>SomeClass</code>, let's say I have a function <code>void function1(std::string)</code>. Is there a way to define something (function, method, ...) to make compiler cast class SomeClass to <code>std::string</code> upon call of <code>function1(object1)</code>? </p>
  
  <p>(I know that I can use stringstream buffer and operator &lt;&lt;, but I'd like to find a way without an intermediary operation like that)</p>