Re: vector and bool

From: Richard Herring (junk_at_[127.0.0.1)
Date: 10/12/04


Date: Tue, 12 Oct 2004 18:12:33 +0100

In message <1097598729.868638@athnrd02>, Ioannis Vranos
<ivr@guesswh.at.grad.com> writes
>Richard Herring wrote:
>
>>> reference is a class that simulates the behavior of references of a
>>>single bit in vector<bool>."
>>
>> That just redefines the semantics of operator[] etc. to return a
>>proxy instead of an actual bool &, thus removing the requirement for
>>elements to have distinct addresses. Nothing there says that it _must_
>>use only use one bit per element.
>
>Well since it says that
>
>"reference is a class that simulates the behavior of references of a
>single bit in vector<bool>"
>
>I think this implies that vector<bool> should be implemented using bits.
>
For a weak enough meaning of "should", I agree that that's the
intention. But I don't think anything in the Standard rules out a naive
implementation that makes no attempt to optimise, and simply implements
vector<bool> in terms of an underlying vector<some_int_type>.

-- 
Richard Herring


Relevant Pages

  • Re: Physics Cultists
    ... In order to prevent "Richard Herring" ... historical documents reference "historical facts" ... with many of their neighbors through history. ... historical facts vs. historical documentation, ...
    (sci.physics)
  • Re: vector and bool
    ... >prohibitions are rare in the standard. ... >Also the implementer has to implement this particular reference: ... >operator bool() const; ... Richard Herring ...
    (comp.lang.cpp)
  • Re: C to Java Byte Code
    ... Richard Herring wrote: ... >> Do you see a reference to C in the sentence above? ... >> optometrist available in your neighborhood? ... kindly kill file this thread if you don't want to see it. ...
    (comp.programming)
  • Re: C to Java Byte Code
    ... Richard Herring wrote: ... >> Do you see a reference to C in the sentence above? ... >> optometrist available in your neighborhood? ... kindly kill file this thread if you don't want to see it. ...
    (comp.lang.cpp)
  • Re: C to Java Byte Code
    ... Richard Herring wrote: ... >> Do you see a reference to C in the sentence above? ... >> optometrist available in your neighborhood? ... kindly kill file this thread if you don't want to see it. ...
    (comp.unix.programmer)