Boost logo

Boost :

Subject: Re: [boost] [fusion] [intro] ADAPT_STRUCT extensions
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-08-15 19:29:34


On 8/16/10 1:01 AM, Stefan Strasser wrote:
> Zitat von Joel de Guzman <joel_at_[hidden]>:
>
>> class foo
>> {
>> public:
>>
>> int x() const;
>> void x(int n);
>> int y() const;
>> void y(int n);
>>
>> private:
>> // encapsulated
>> };
>>
>> Now, adapt that class to fusion.
>
> is the goal a (mutable) fusion sequence with value type int?
> then there is no solution, as the class only exposes the value of its
> members.
> if the goal is just any representation of the class in sequence form,
> I'd suggest to make the (now transparent) proxy object visible to the user.

[snip]

And as a matter of fact, that IS the intent. The proxy object is a public
class in namespace boost::fusion::extension named class_member_proxy (terser
name suggestion welcome).

I hope you guys see now from the example above that it is a very typical
representation of an OOP *class*. I'd say that this example is the most
common form of class that needs to be adapted and that the only way
to satisfy this requirement is to do it the way it is done now. It's
not perfect, it's not as clean as I hoped. I too don't like proxies
since C++ does not allow you to write perfect proxies. But I see no
other way around.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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