This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: a string problem
- To: <scleary at jerviswebb dot com>
- Subject: Re: a string problem
- From: Gabriel Dos Reis <dosreis at cmla dot ens-cachan dot fr>
- Date: 13 Oct 1999 15:00:19 +0200
- Cc: "'libstdc++ mailing list'" <libstdc++ at sourceware dot cygnus dot com>
- Organization: CMLA, ENS Cachan -- CNRS URA 1611 (France)
- References: <538B4E4235ECD211B35B0090273CC28B012D87@CECEXCHANGE>
- Reply-To: libstdc++ at sourceware dot cygnus dot com
scleary@jerviswebb.com writes:
| > > #include <string>
| > >
| > > void foo() { std::string s(10,0); }
| >
| > whoops. This is not a compiler or library implementation bug--the
| > arugments get deduced as iterators, as you pointed out earlier. You'll
| > have to cast to
| >
| > string s(10, char(0)) to call the constructor that you're intending.
| >
|
| I beg to differ. It is an implementation bug, according to ANSI 21.3.1 para
| 15, which states for constructor "template <class InputIterator>
| basic_string(InputIterator begin, InputIterator end, const Allocator & a =
| Allocator());": "If InputIterator is an integral type, [this constructor
| call is] equivalent to 'basic_string(static_cast<size_type>(begin),
| static_cast<value_type>(end))'" Also see ANSI 23.1.1 para 9-11.
Actually you're right. It just happens that the reported bug appears
to be known... Let me quote from libstdc++/docs/17_intro/TODO:
===
- fix template members of basic_string<> to overload iterators and
non-iterators properly. (This is the infamous hack as in vector<> etc
23.1.1 para 10.)
===
-- Gaby