title: Template for regex search
body: <pre><code>#include &lt;regex&gt;
  #include &lt;string&gt;
  
  template &lt;typename T&gt;
  auto RegexSearch(const std::basic_string&lt;T&gt;&amp; str, 
                   const std::basic_string&lt;T&gt;&amp; regex)
  {
      using iter = typename std::basic_string&lt;T&gt;::const_iterator;
      std::basic_regex&lt;T&gt; re(regex);
      std::match_results&lt;iter&gt; m;
      std::regex_search(str, m, re);
      return m;
  }
  
  // call example
  auto match = RegexSearch(L&quot;[0,1,2,3]&quot;s
      , LR&quot;((\d+))&quot;s);
  </code></pre>
  <p>Inside of the template scope, <code>m</code> stores correct values, but <code>auto match = RegexSearch(...)</code></p>
  <p><code>match</code> contain only garbage, what's going on?</p>
  <p>-Edit-</p>
  <pre><code>template &lt;typename T&gt;
  auto RegexSearch(const std::basic_string&lt;T&gt;&amp; str,
      const std::basic_string&lt;T&gt;&amp; regex)
  {
      using iter = typename std::basic_string&lt;T&gt;::const_iterator;
      std::basic_regex&lt;T&gt; re(regex);
      std::match_results&lt;iter&gt; m;
      std::regex_search(str, m, re);
  
      std::vector&lt;std::basic_string&lt;T&gt;&gt; match{};
      match.emplace_back(m[0]);
      match.emplace_back(m.prefix());
      match.emplace_back(m.suffix());
      return match;
  }
  </code></pre>
  <p><code>RegexSearch</code> will be always just 1 value returned correct?</p>
  <p>Is it 'wrong' to do such a thing?</p>