This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: a string problem


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]