Re: vector and bool
From: Richard Herring (junk_at_[127.0.0.1)
Date: 10/13/04
- Next message: Karthik Kumar: "Re: FFTW execution"
- Previous message: Phlip: "Re: Things I hate about C++"
- In reply to: Ioannis Vranos: "Re: vector and bool"
- Next in thread: Ioannis Vranos: "Re: vector and bool"
- Reply: Ioannis Vranos: "Re: vector and bool"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 13 Oct 2004 10:12:50 +0100
In message <1097606565.479989@athnrd02>, Ioannis Vranos
<ivr@guesswh.at.grad.com> writes
>Richard Herring wrote:
>
>> 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>.
>
>
>There is not an explicit prohibition on this, however explicit
>prohibitions are rare in the standard.
Just so. The standard specifies an interface and complexity (speed)
requirements, not the mechanism used to implement them. But it says
nothing prescriptive about the memory requirements for containers.
>
>Also the implementer has to implement this particular reference:
>
>
>// bit reference:
>class reference {
>friend class vector;
>reference();
>public:
>˜reference();
>operator bool() const;
>reference& operator=(const bool x);
>reference& operator=(const reference& x);
>void flip(); // flips the bit
>};
>
Yes, and the fact that this is what operator[] is mandated to return is
what makes it *possible* for the implementor to provide access to data
packed into something smaller than an addressable unit.
>
>with the note:
>
>reference is a class that simulates the behavior of references of a
>single bit in vector<bool>.
Yes; note the word "simulates".
>
>and this particular member function:
>
>void flip(); // flips all bits
>
>Also vector<bool> is mentioned as a separate case in the standard, and
>thus I think the legislator intended this to be implemented only with
>bits.
I'd say "intended it to be _possible_ to implement with bits".
>:-)
-- Richard Herring
- Next message: Karthik Kumar: "Re: FFTW execution"
- Previous message: Phlip: "Re: Things I hate about C++"
- In reply to: Ioannis Vranos: "Re: vector and bool"
- Next in thread: Ioannis Vranos: "Re: vector and bool"
- Reply: Ioannis Vranos: "Re: vector and bool"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|