title: Can one leverage std::basic_string to implement a string having a length limitation?
body: <p>I'm working with a low-level API that accepts a <code>char*</code> and numeric value to represent a string and its length, respectively.  My code uses <code>std::basic_string</code> and calls into these methods with the appropriate translation.  Unfortunately, many of these methods accept string lengths of varying size (i.e. max(<code>unsigned char</code>), max(<code>short</code>), etc...) and I'm stuck writing code to make sure that my string instances do not exceed the maximum length prescribed by the low-level API.</p>
  
  <p>By default, the maximum length of an <code>std::basic_string</code> instance is bound by the maximum value of <code>size_t</code> (either max(<code>unsigned int</code>) or max(<code>__int64</code>)).  Is there a way to manipulate the  traits and allocator implementations of a <code>std::basic_string</code> implementation so that I may specify my own type to use in place of <code>size_t</code>?  By doing so, I am hoping to leverage any existing bounds checks within the <code>std::basic_string</code> implementation so I don't have to do so when performing the translation.</p>
  
  <p>My initial investigation suggests that this is not possible without writing my own string class, but I'm hoping that I overlooked something :)</p>