title: Initialize std::string and std::wstring from the same hard coded string literals
body: <p>I was writing some unit-tests when I stumbled upon a scenario that managed to bug me a couple of times already.</p>
  
  <p>I need to generate some strings for testing a JSON writer object. Since the writer supports both UTF16 and UTF8 inputs, I want to test it with both.</p>
  
  <p>Consider the following test:</p>
  
  <pre><code>class UTF8;
  class UTF16;
  
  template &lt; typename String, typename SourceEncoding &gt;
  void writeJson(std::map&lt;String, String&gt; &amp; data)
  {
      // Write to file
  }
  
  void generateStringData(std::map&lt;std::string, std::string&gt; &amp; data)
  {
      data.emplace("Lorem", "Lorem Ipsum is simply dummy text of the printing and typesetting industry.");
      data.emplace("Ipsum", "Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book");
      data.emplace("Contrary", "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old");
  }
  
  void generateStringData(std::map&lt;std::wstring, std::wstring&gt; &amp; data)
  {
      data.emplace(L"Lorem", L"Lorem Ipsum is simply dummy text of the printing and typesetting industry.");
      data.emplace(L"Ipsum", L"Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book");
      data.emplace(L"Contrary", L"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old");
  }
  
  template &lt; typename String, typename SourceEncoding &gt;
  void testWriter() {
      std::map&lt;String, String&gt; data;
      generateStringData(data);
      writeJson&lt;String, SourceEncoding&gt;(data);
  }
  
  int main() {
      testWriter&lt;std::string, UTF8&gt;();
      testWriter&lt;std::wstring, UTF16&gt;();
  }
  </code></pre>
  
  <p>I manage to wrap everything nicely except for the duplicate <code>generateStringData()</code> method. <strong>And I was wandering if it's possible to combine both <code>generateStringData()</code> methods into a single one?</strong></p>
  
  <p>I know I could use a single method to generate strings in UTF8 and then use an additional method to convert the strings to UTF16, but I'm trying to find out if there's another way.</p>
  
  <p>What have I considered/tried?</p>
  
  <ul>
  <li>Using <code>_T()</code> or <code>TCHAR</code> or <code>#ifdef UNICODE</code> won't help, since I need both flavors on the same platform that supports Unicode (e.g. Win >= 7)</li>
  <li>Initializing <code>std::wstring</code> from something that is not <code>L""</code> won't work since it expects a wchar_t</li>
  <li>Initializing char by char won't work since it also requires <code>L''</code></li>
  <li>Using <code>""s</code> won't work since the return type depends on type <code>charT</code></li>
  </ul>