This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Curious issue with char_traits
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: 25 Oct 2005 18:38:37 +0200
- Subject: Re: Curious issue with char_traits
- References: <435E304A.1000504@suse.de>
Paolo Carlini <pcarlini@suse.de> writes:
| Hi,
|
| while answering privately a message from a user, I noticed a curious
| glitch. Consider this:
|
| --------
| #include <string>
|
| using namespace __gnu_cxx;
| using namespace std;
|
| typedef basic_string<char, char_traits<char>, allocator<char> > mystr;
| --------
|
| Well, doesn't compile!
|
| plain.cc:6: error: 'char_traits' was not declared in this scope
| plain.cc:6: error: missing '>' to terminate the template argument list
| plain.cc:6: error: template argument 2 is invalid
| plain.cc:6: error: expected unqualified-id before '>' token
|
| The problem is that our "extended" char_traits implementation involves a
| template struct named char_traits *both* in __gnu_cxx and in std (which
| uses the former). But __gnu_cxx is the namespace where all our extension
| facilities live and as soon as a user does 'using namespace __gnu_cxx;'
| (I think it can be common), then char_traits becomes ambiguous (an
| additional std:: qualifier becomes necessary)
|
| I think we should fix this, i.e., we should render std::char_traits
| robust wrt using-directives. What about renaming __gnu_cxx::char_traits
| to something like __gnu_cxx::__char_traits? This would fix the problem
| at issue and it would still be possible to specialize
| __gnu_cxx::__char_traits.
|
| Opinions?
That is the tip of the iceberg. Following the wisdom of someone who
is opposed to cover up, I'm opposed to __char_traits as a fix to the
real problem.
-- Gaby