This is the mail archive of the
libstdc++-prs@sources.redhat.com
mailing list for the libstdc++ project.
libstdc++/93: template class basic_string cannot be instantiated with types other than <char>
- To: libstdc++-gnats at sourceware dot cygnus dot com
- Subject: libstdc++/93: template class basic_string cannot be instantiated with types other than <char>
- From: joel at quoininc dot com
- Date: 28 Sep 2000 18:27:39 -0000
- Reply-To: joel at quoininc dot com
- Resent-Cc: libstdc++-prs at sourceware dot cygnus dot com
- Resent-Reply-To: libstdc++-gnats@sourceware.cygnus.com, joel@quoininc.com
>Number: 93
>Category: libstdc++
>Synopsis: template class basic_string cannot be instantiated with types other than <char>
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Sep 28 11:37:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Joel Roth-Nater
>Release: 2.95.2-51
>Organization:
>Environment:
libgpp.rpm on SuSE-Linux
>Description:
std/bastring.h:334
const charT* c_str () const
{ if (length () == 0) return ""; terminate (); return data (); }
This causes a compiler error if "" (or char*) cannot be
implicitly converted into charT*.
>How-To-Repeat:
instantiate a wide-char version of basic_string:
typedef basic_string<short> wstring;
>Fix:
As a workaround, I created my own version of the header file
which casts "" explicitly to charT*:
std/bastring.h:334
const charT* c_str () const
{ if (length () == 0) return (charT*) L""; terminate (); return data (); }
This will still link with the original lib. I just have to make
sure I include my header file before anything STL.
It would be cleaner IMO to do this:
static const charT empty_str = 0;
const charT* c_str () const
{ if (length () == 0) return &empty_str; terminate (); return data (); }
>Release-Note:
>Audit-Trail:
>Unformatted: