title: Easy way to cout any struct in c++
body: <p>In c++, is there a way to define a function that prints every struct? I mean, in our project, there are lots of structs; I need to print them sometimes, to debug. I want them to be printed easily, without adding friend ostream function to the every struct.</p>
  <pre class="lang-cpp prettyprint-override"><code>struct type{
      string name;
      int id;
  }
  type aType;
  aType.name= &quot;sahin&quot;;
  aType.id=10;
  </code></pre>
  <p>The function can work like this:</p>
  <pre class="lang-cpp prettyprint-override"><code>printStruct(aType);
  
  output:
  {
      name:sahin
      id:10
  }
  </code></pre>
  <p>And then, if possible, I need a way to print vectors of structs.
  Similar to JSON.stringify in js.</p>