Is there any use for basic_string<T> where T is not a character type? : <p>The declaration of C++ string <a href="http://en.cppreference.com/w/cpp/string/basic_string" rel="noreferrer">is the following</a>:</p>

<pre><code>template&lt; 
    class CharT, 
    class Traits = std::char_traits&lt;CharT&gt;, 
    class Allocator = std::allocator&lt;CharT&gt;
&gt; class basic_string;
</code></pre>

<p>The <code>CharT</code> is character type which can be <code>char</code>, <code>wchar_t</code>, <code>char16_t</code> and <code>char32_t</code>; but after all <code>basic_string</code> is a template so can be instantiated with other <code>CharT</code> and other allocators. While I can think in some use cases for other allocators I'm unable to think in use cases for strings of other data types, for example:</p>

<pre><code>using string = std::basic_string&lt;int&gt;;
</code></pre>

<p>Using a string of integers, we cannot initialize it as a string (obvious) nor u32 string (not that obvious, at least for me); but we can initialize it with <code>initializer_list</code> as long as the contained type of the list is convertible to <code>int</code>:</p>

<pre><code>string err1("test");   // Error!
string err2(U"test");  // Error!
string err3{"test"};   // Error!
string err4{U"test"};  // Error!
string err5 = "test";  // Error!
string err6 = U"test"; // Error!

string success1({U't', U'e', U's', U't'});
string success2 = {U't', U'e', U's', U't'};
string success3({'t', 'e', 's', 't'});
string success4 = {'t', 'e', 's', 't'};
</code></pre>

<p>But even if we manage to initialize a integer string, we cannot use it in the normal way:</p>

<pre><code>std::cout &lt;&lt; success1; // Error! expected 116101115116
</code></pre>

<p>The only <code>basic_string</code> expected to be used with <code>cout</code> are the <em>normal</em> ones, that makes sense: after all we cannot assume how is supposed to be printed a string of integers or a string of <code>MyFancyClass</code>es.</p>

<p>But anyways, the creation of <em>strange</em> instances of <code>basic_string</code> isn't forbidden; on one hand is not forbidden due to the lack of features which forbids that use (a.k.a. concepts) and on the other coding <code>basic_string</code> without limiting the underlying type is easier than doing it on the opposite way (without concepts) so, that makes me wonder:</p>

<ul>
<li>Is there any use for <code>std::basic_string&lt;T&gt;</code> where <code>T</code> is not a character type?</li>
</ul>

<p>As for <em>any use</em> I'm thinking about things that only can be achieved with strings of <code>T</code> and that cannot be done with vector of <code>T</code> (or it will be significantly harder to do), in other words:</p>

<ul>
<li>Have you ever faced a situation where a string of <code>T</code> is the better choice?</li>
</ul>
