Topic: vector<bool>::iterator


Author: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
Date: 1999/05/30
Raw View
Hi,

I'm compiling a small testsuite for the STL part of the standard library
and I'm having problems with finding out which requirements vector<bool>
is supposed to fulfill. In particular, am I correct in assuming that
vector<bool>::iterator isn't a forward iterator? Table 74 (forward
iterator requirements) states that *a has to return T& if a is a forward
iterator but presumably, vector<bool>::iterator will return
vector<bool>::reference here. BTW, are tables 75 and 76 correct in
requiring the result of *a-- and a[n] to be just convertible to T and
not T&? I don't want to restart the old debate again, I just want to
clarify these issues now that the standard is finished.

Bye

Roman
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Dave Abrahams" <abrahams@mediaone.net>
Date: 1999/05/30
Raw View
In article <375104FA.AF96A6CA@cs.tu-berlin.de> , Roman Lechtchinsky
<wolfro@cs.tu-berlin.de>  wrote:

> I'm compiling a small testsuite for the STL part of the standard library
> and I'm having problems with finding out which requirements vector<bool>
> is supposed to fulfill. In particular, am I correct in assuming that
> vector<bool>::iterator isn't a forward iterator? Table 74 (forward
> iterator requirements) states that *a has to return T& if a is a forward
> iterator but presumably, vector<bool>::iterator will return
> vector<bool>::reference here. BTW, are tables 75 and 76 correct in
> requiring the result of *a-- and a[n] to be just convertible to T and
> not T&? I don't want to restart the old debate again, I just want to
> clarify these issues now that the standard is finished.

You're right: this exact issue (or at least an issue intimately related)
came before the C++ committee in Dublin. Someone suggested removing the
specialization for vector<bool>, but we clearly couldn't do that without
breaking code (note that vector<bool>::reference has a member function
called flip). Clearly, the use of such proxies is in fact outlawed by the
standard (capital 'C')-Container requirements in the standard. Also clearly,
many people find proxies useful in containers. If you want to write generic
code for containers which may use proxies, you'll need to invent a new,
looser distinction with its own set of requirements. You could call it
"ProxyContainer".
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: hsutter@peerdirect.com (Herb Sutter)
Date: 1999/05/31
Raw View
On 30 May 99 16:27:38 GMT, Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
wrote:
>I'm having problems with finding out which requirements vector<bool>
>is supposed to fulfill. In particular, am I correct in assuming that
>vector<bool>::iterator isn't a forward iterator?

Alas, yes.

>I don't want to restart the old debate again, I just want to
>clarify these issues now that the standard is finished.

This issue is being considered by the committee. For more details about
this problem, see also the current (May99) C++ Report.

Herb

---
Herb Sutter (mailto:hsutter@peerdirect.com)

PeerDirect Inc.     2695 North Sheridan Way, Suite 150
www.peerdirect.com  Mississauga Ontario Canada L5K 2N6
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]