This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: user-defined types and basic_string
- From: "Anthony Feick" <afeick at hotmail dot com>
- To: bkoz at redhat dot com, gdr at integrable-solutions dot net
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 29 Aug 2002 11:25:47 -0500
- Subject: Re: user-defined types and basic_string
- Bcc:
Thank you for posting the example for an "unsigned short" basic_string. I
didn't get a chance to get back to this until yesterday, but had some
problems with the final example you posted.
I was unable to implicitly create characters from integers :
basic_string<char_type> theString;
theString.append(0x20);
theString.append('o');
No amount of casting was able to fix this, and constructors in character<T>
will not work because then it isn't Plain Old Data (POD??). With a
constructor it can't be used in a union, among other problems.
I ended up not using templates at all, instead just defining char_traits as:
namespace std
{
struct char_traits<unsigned short>
{
typedef unsigned short char_type;
.
.
.
};
};
Unless you know of an 'elegant' way to go from an int to a character, this
will have to do.
Thanks,
Tony
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx