|
Boost : |
Subject: Re: [boost] [fusion] [intro] ADAPT_STRUCT extensions
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-07-31 11:18:37
Zitat von Christopher Schmidt <mr.chr.schmidt_at_[hidden]>:
> I patched the code in the trunk to enable the adaption of private
> attributes. The adaptee just needs to friend "struct
> boost::fusion::extension::access". See changeset 64490
> (https://svn.boost.org/trac/boost/changeset/64490) for details.
great!
one small thing, could you change "struct access" to "class access"?
MSVC complains if the key differs between the definition and the
friend declaration, and I think people are more used to "friend class"
(in general, and because of "class serialization::access")
is there a rationale for the "extension" namespace somewhere online?
anything that uses the extension mechanism is in the extension namespace?
>
> Regarding the second feature request: I am not in favor of adding yet
> another set of BOOST_FUSION_ADAPT_xxx-macros.
>
> struct A{int x;};
> struct B{int y;};
> struct C : A,B{int z;};
> BOOST_FUSION_ADAPT_STRUCT(A, (int,x))
> BOOST_FUSION_ADAPT_STRUCT(B, (int,y))
I understand the problem, but I don't think we have a solution yet.
thanks for the idea with segmented sequences, but it looks like a
workaround to me, because what does...:
> BOOST_FUSION_ADAPT_STRUCT(C, (int,z))
...mean?
it says that it adapts the struct C, but it doesn't adapt C, it adapts
the most-derived-level of C.
is there even a use case for this? why would you want to do that?
if there isn't you could say that ADAPT_STRUCT can not be used for
derived classes. you need another macro.
adapting the whole struct C the way you suggested would always require
writing (if I hide all your code behind 1 new macro):
BOOST_FUSION_ADAPT_STRUCT_NAMED(C,BOOST_PP_EMPTY(),C_derlevel, (int,z) )
BOOST_FUSION_ADAPT_ALL_OF_STRUCT(C,C_derlevel,(A)(B) )
I'd prefer adding new macros to that, e.g. ADAPT_SUBCLASS.
wrt a solution without adding new macros I only see one using C99
variadic macros.
do you know what's the state of those? last I checked the compilers I
use implemented them, and I think they will be part of c++0x because
they are part of C99. but there was also a bug in MSVC's
implementation which I don't know can be worked around.
with variadic macros the adaption of C could look like this:
BOOST_FUSION_ADAPT_STRUCT(C, (A) (B) (int,z) )
with no new macros.
Stefan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk