Boost logo

Boost :

From: Frank Laub (frank.laub_at_[hidden])
Date: 2005-12-22 04:28:15


On 12/21/05, Richard Jennings <richard.jennings_at_[hidden]> wrote:
>
> I'm stuck with a basic problem with BOOST_BITFIELD, again using BCB6 and
> compiling enum.cpp included with the library.
>
> The lines:
> MouseKey A, B;
> A |= B;
> fail to compile with 'bitfield_base<MouseKey>::m_value is not accessible'
> in operator |= in bitfield.hpp.
>
> Not sure what's intended here. It would seem that if the following
> function is being instantiated:
> void bitfield_base<MouseKey>::operator |= (const MouseKey& rhs)
> {
> m_value |= rhs.m_value;
> }
> then m_value is not accessible since it's private to bitfield_base. If
> rhs were of type bitfield_base then it would work.

Well this is weird. The intent is for the Boost.Operators library to see
that it can take a MouseKey on the rhs and thereby generate the binary op
for me. Since this method is implemented in bitfield_base, it seems that
there would be no problem for it to have access to m_value.

Changing bitfield_base as follows:
> void operator |= (const bitfield_base<T>& rhs)
> {
> m_value |= rhs.m_value;
> }

If I make the return value be void, the Boost.Operators library goes nuts. I
can change the rhs type I suppose, that shouldn't hurt anything. I realize I
am returning a derived type, but it should be ok because the derived type
doesn't have any memory associated with it; all data is in the base.

-Frank


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