Boost logo

Boost :

Subject: Re: [boost] [fusion] getting type of attribute_proxy for BOOST_FUSION_ADAPT_ADT
From: Jens Weller (JensWeller_at_[hidden])
Date: 2016-03-04 11:32:13


> [snip]
> >>
> >> Hi Jens,
> >>
> >> Try attribute_proxy::type. It's documented here:
> >> http://www.boost.org/doc/libs/1_50_0/libs/fusion/doc/html/fusion/notes.html#fusion.notes.adt_attribute_proxy
> >
> > Hi Joel,
> >
> > great!
> >
> > Is there a generic way to detect which sort of Adapted struct it is?
> > typename fusion::result_of::at_c<Seq, I>::type::type t;
> > Will probably only work for proxies, which would be fine for my code.
>
> Hmmm, well adt_attribute_proxy only happens, erm with proxies. So I guess the
> more relevant question is, how do you easily detect if at_c or any iterator
> function returns a proxy(?). Alas, there's no easy way at the moment. It's
> easy to add one and perhaps that might be a good idea. Please file a ticket
> and I'll see what I can do.

Ticket created under:
https://svn.boost.org/trac/boost/ticket/12041

Which brings me to another fusion question/improvement:
ADT structs don't know their member names, which can be fixed with such a construct:
#define ADT_MEMBER_NAME(CLASS, INDEX, MEMBER) \
template <> struct struct_member_name<CLASS, INDEX> { typedef char const *type; static type call() { return #MEMBER; } };

namespace boost { namespace fusion { namespace extension {
        ADT_MEMBER_NAME(ListEntry, 0, text)
...
        ADT_MEMBER_NAME(ListEntry, 6, published)
} } }

Could that be integrated into the BOOST_FUSION_ADAPT_STRUCT_ADT etc. macros?

thanks,

Jens Weller


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