title: a sleek C++ variadic named test output
body: <p>I've made some variadic output macros, especially for test output purposes.
  Examples: C++-code // output: function file(first and last char) linenumber variable=value</p>
  <pre><code>L(i,b); // result e.g. {evenRCpower@ih2943: i=36 b=1  @}
  L(hex,pd,dec,check.back(),even,&quot;e.g.&quot;); 
    // result e.g.: {way@ih3012:  pd=babbbaba  check.back()=15216868001 even=1 e.g.  @}
  </code></pre>
  <p>They are working fine, having some minor restrictions, which can be lowered by more text analysis (restricted usage of comma and output specifications).
  Up to now, they are working at least under g++1z and c++1z.
  My questions:</p>
  <ol>
  <li><em>Main question</em>: How to get the macro completely thread safe?</li>
  <li>Is there a solution needing no textual analysis, e.g. to avoid #<strong>VA_ARGS</strong> and get the names for every parameter separated?</li>
  <li>How to distinguish parameters from output manipulators (necessary)?</li>
  <li>What's to change for other (newer) C++ and g++ versions?</li>
  <li>Even to write one complete line into one local string using a locally defined outstream isn't completely solving the problem of output mixing in parallel work - but why? In which C++ version this problem will be solved?
  I'll give a simplified base version with use of &quot;std::out&quot; will work fine, but of course give bad results, when used in parallel threads:</li>
  </ol>
  <pre><code>#define WO_IS 1
  #define L(...) locate(__FILE__,__LINE__,__func__,&quot;\n{&quot;,&quot;: &quot;,&quot; @}\n&quot;,#__VA_ARGS__,##__VA_ARGS__)
  
  string argTExcludes = &quot; hex dec std::hex std::dec &quot;, funcExcludes = &quot; setprecision &quot;;
  
  string argT(const string sarg,int &amp;nextpos) { // NO exact analysis!! Simple strings and chars allowed, but parameters with commata like in f(x,y,&quot;A,&quot;,','): crazy output !! 
    int i = nextpos+1, pos = i, follow = 0; string nom; bool apo = false; 
    for (; i &lt; sarg.size(); i++) 
      if(sarg.at(i) == ' ') { ;
      } else if ((sarg.at(i) == ',')||(i == (sarg.size()-1))) { 
        nom = sarg.substr(pos,i-pos);
        if (argTExcludes.find(nom) != std::string::npos) { nextpos = i; return &quot;&quot;; };
        break;
      } else {
        if ((sarg.at(i) != ' ') &amp;&amp; (!follow++) &amp;&amp; ((sarg.at(i) == '&quot;')||(sarg.at(i) == '\'')) ) apo = true; 
        if ((sarg.at(i) == '&quot;') &amp;&amp; ( (i==0)||((i &gt; 0) &amp;&amp; (sarg.at(i-1) != '\'')) )) { i++; while ((sarg.at(i) != '&quot;') &amp;&amp; (i &lt; sarg.size())) i++; };
        if (sarg.at(i) == '(') { 
          nom = sarg.substr(pos,i-pos); if (funcExcludes.find(nom) != std::string::npos) apo = true; 
        };
      };
    nextpos = i;
    return (apo)?&quot;&quot;:sarg.substr(pos,i-pos)+&quot;=&quot;;
  };
  
  template &lt;typename... Ts&gt;
  inline void locate(string ort,long line,string funct,const string prefix, const string trenner, const string postfix, string sarg, Ts... args) 
  { 
  #if WO_IS &gt; 0 // all range restrictions abandoned
      int pos = -1; bool apo; sarg += &quot;,&quot;;
      std::ios_base::fmtflags f( cout.flags() );
      std::cout &lt;&lt; prefix &lt;&lt; funct &lt;&lt; '@' &lt;&lt; ort[0] &lt;&lt; ort.back() &lt;&lt; dec &lt;&lt; line &lt;&lt; trenner; 
      cout.flags( f );
      ((std::cout &lt;&lt; argT(sarg,pos) &lt;&lt; args &lt;&lt; ' '), ...); // forbidden: endl - it will give syntax error even when no blank at end 
      // ((std::cout &lt;&lt; argT(sarg,pos); std::cout &lt;&lt; args; std::cout &lt;&lt; ' '), ...); // forbidden: endl - it will also give syntax error
      if (postfix == &quot;\0&quot;) std::cout.flush();
      else std::cout &lt;&lt; postfix; //  &lt;&lt; endl; 
  #endif
  };
  </code></pre>