title: string_t from(wstring OR string) when string_t can also be typedef of both
body: <pre><code>namespace settings{
    typedef wchar_t char_t;
    typedef std::basic_string&lt;char_t&gt; string_t;
  }
  
  namespace util{
    namespace string{
      std::basic_string&lt;wchar_t&gt;  toWide(const std::basic_string&lt;char&gt;&amp;      s);
      std::basic_string&lt;char&gt;     fromWide(const std::basic_string&lt;wchar_t&gt;&amp; w);
    }
  }
  </code></pre>
  
  <p>This is what I've. <code>char_t</code> may be <code>wchar_t</code> or <code>char</code>. Now I want two functions that intelligently convert the input string <code>settings::string_t</code> </p>
  
  <pre><code>settings::string_t  from(const std::basic_string&lt;char&gt;&amp; s);
  settings::string_t  from(const std::basic_string&lt;wchar_t&gt;&amp; s);
  </code></pre>
  
  <p>using <code>boost::is_same</code> doesn't work on <code>return s</code> because <strong>string_t typedef'ed as wstring but returns string</strong></p>
  
  <pre><code>settings::string_t util::string::from(const std::basic_string&lt; char &gt;&amp; s){
    if(boost::is_same&lt; std::basic_string&lt;char&gt; , settings::string_t &gt;::value){
      return s;
    }else{
      return toWide(s);
    }
  }
  </code></pre>
  
  <p>It is east to identify whether <code>InputType</code> and <code>string_t</code> is same or not using template as well as overloads, but If they are not same then there comes 4 variations. </p>
  
  <p>How to model this scenario <strong>without overloading type operator</strong> ?</p>
  
  <h2>Summary</h2>
  
  <p>How can I design the <code>settings::string_t from(const std::basic_string&lt;T&gt;&amp; s);</code> that converts both <code>char</code> and <code>wchar</code> strings to <code>string_t</code>. Where T can also be <code>char</code> or <code>wchar_t</code>. and you can see in the question <code>string_t</code> is flexible. it can also be both <code>char</code> or <code>wchar_t</code> strings</p>