Discussion:
basic_string specialization problem
(too old to reply)
Gilbert Chang
2003-10-18 01:03:37 UTC
Permalink
The standard C++ library does not seem to pre-instantiate the basic_string
specialization with unsigned short. I couldn't manually get g++ to
instantiate it either. The problem can be reproduced with the following
code. This is with g++ v3.2. Any idea? Thanks.

#include <string>

typedef unsigned short Chr;

typedef std::basic_string<Chr, std::char_traits<Chr>, std::allocator<Chr> >
ustring;

int main(void) {

unsigned short c = 0x1234;

ustring s(&c);

ustring s2 = s;

}
Erik Max Francis
2003-10-18 03:09:25 UTC
Permalink
Post by Gilbert Chang
The standard C++ library does not seem to pre-instantiate the
basic_string
specialization with unsigned short. I couldn't manually get g++ to
instantiate it either. The problem can be reproduced with the
following
code. This is with g++ v3.2. Any idea? Thanks.
Why do you think it should? The reason traits and allocators exist is
precisely so that you can define those things yourself. If you want
something other than std::basic_string<char> or
std::basic_string<wchar_t>, you're going to have to define the traits
yourself.
--
Erik Max Francis && ***@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Don't want you to leave / And I don't want to leave you
\__/ Chante Moore
Loading...