Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2002-06-13 23:37:49


Seeing the dyn_bitset code, I wonder if we should have the bit_reference
class as a separate library, that other bit-packing code can use. The
structure could be like this:

template < typename BlockType >
class const_bit_reference
{
    BlockType const & ref_;
    std::size_t const pos_;

public:
    const_bit_reference( BlockType const &, std::size_t );

    operator bool() const;

    bool operator !() const;
};

template < typename BlockType >
class bit_reference
{
    BlockType & ref_;
    std::size_t const pos_;

public:
    bit_reference( BlockType &, std::size_t );

    operator bool() const;
    operator const_bit_reference<BlockType>() const;

    bool operator !() const;

    bit_reference & operator =( const_bit_reference const & );
    bit_reference & operator =( bit_reference const & );
    bit_reference & operator =( bool );

    void flip();
};

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk