Boost logo

Boost Users :

Subject: Re: [Boost-users] [Fusion] Output of adapted ADT
From: TONGARI (tongari95_at_[hidden])
Date: 2011-04-09 03:39:56


2011/4/9 Joel de Guzman <joel_at_[hidden]>

> Adapted classes are different beasts. Adapted classes may not
> expose their attributes by reference due to abstraction and
> information hiding. It's not uncommon for a class not to actually
> have an actual member variable. The best we can assume is that a
> class has a getter and setter member functions. When you access
> its member (e.g. using at_c or dereferencing an iterator), here's
> what happens:
>
> 1) If the adapted class is immutable, it returns the class' adapted
> get member function for the member.
>
> E.g. T get_mem() const;
>

Really? Right after seeing your words I almost came up with a workaround...
However, it turns out that it's either me misunderstanding you or it
misbehaving.

For example,
    const foo f("foo"); // immutable, right?
    boost::fusion::front(f); // we still get a proxy, why?

2) If the adapted class is mutable (your case), then it returns a
> proxy, that when assigned to, calls the class' adapted set member
> function for the member.
>
> E.g. void set_mem(T const&);
>
> The proxy also has a conversion to T which then returns the class'
> adapted get member function for the member.
>
> That's the best we can do.
>

Do you have any suggestion for using adapted class with Spirit that the OP
wants to do?

Thanks.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net