BOOST_FUSION_ADAPT_STRUCT: non intrusive macro, get a fusion sequence of struct member types and member names
Hello, I am aware that it is planned to implement metafunctions that returned the list of member types of a struct, as well as members names, as fusion/mpl sequences. The macro uses some PP magic. My project has progressed that I think I need this feature to proceed. I may try my hand at implementing these features... Which files in boost/fusion are involved in the implementation of the macro? regards,
On 1/24/2010 8:29 PM, Hicham Mouline wrote:
Hello, I am aware that it is planned to implement metafunctions that returned the list of member types of a struct, as well as members names, as fusion/mpl sequences. The macro uses some PP magic. My project has progressed that I think I need this feature to proceed. I may try my hand at implementing these features... Which files in boost/fusion are involved in the implementation of the macro?
See boost/fusion/adapted/struct. The member types are already provided through result_of::at_c. The names are not (yet). Be warned, I have to insist on updating the docs too :-) Ahem ahem... Do tell us your proposed interface. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon
----- Original Message -----
From: "Joel de Guzman"
On 1/24/2010 8:29 PM, Hicham Mouline wrote:
Hello, I am aware that it is planned to implement metafunctions that returned the list of member types of a struct, as well as members names, as fusion/mpl sequences. The macro uses some PP magic. My project has progressed that I think I need this feature to proceed. I may try my hand at implementing these features... Which files in boost/fusion are involved in the implementation of the macro?
See boost/fusion/adapted/struct. The member types are already provided through result_of::at_c. Of course (this is the kind of mistakes beginners do, not paying attention:-( )
The names are not (yet). Be warned, I have to insist on updating the docs too :-) Ahem ahem...
Do tell us your proposed interface. One way is to return a fusion sequence of as many "const char*" as there are members in the struct, so the types are "const char*" and the runtime values are the member names. That wouldn't suit my case as I wouldn't be able to generate the spirit grammar wiht PP at compile-time.
How can the member names be stored in the type information of the fusion /mpl sequence as const char* ?
From what I understand, you can only have template non-type arguments that have an external linkage. Hmmm, I don't know.
Docs, absolutely, glad to make any contribution. I need to read up about quickbook, right? regards,
----- Original Message -----
From: "Joel de Guzman"
Do tell us your proposed interface.
Perhaps also a metafunction struct_member_name_at/at_c< index, struct_adapted_as_fusion_sequence > hmm, it's the same problem with the const char* Is there no way to provide the member names at compile time? There must be something obvious and I am just not seeing it. rds,
struct_member_name_at/at_c< index, struct_adapted_as_fusion_sequence > hmm, it's the same problem with the const char*
Is there no way to provide the member names at compile time? There must be something obvious and I am just not seeing it. name will obviously be char* and you can't have that in a template
Hicham Mouline wrote: parameter. Best shot is to generate types with name looking like member name. -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
On 1/25/2010 6:54 PM, joel falcou wrote:
struct_member_name_at/at_c< index, struct_adapted_as_fusion_sequence > hmm, it's the same problem with the const char*
Is there no way to provide the member names at compile time? There must be something obvious and I am just not seeing it. name will obviously be char* and you can't have that in a template
Hicham Mouline wrote: parameter. Best shot is to generate types with name looking like member name.
I think it should just be simple functions:
template
----- Original Message -----
From: "Joel de Guzman"
On 1/25/2010 6:54 PM, joel falcou wrote:
struct_member_name_at/at_c< index, struct_adapted_as_fusion_sequence > hmm, it's the same problem with the const char*
Is there no way to provide the member names at compile time? There must be something obvious and I am just not seeing it. name will obviously be char* and you can't have that in a template
Hicham Mouline wrote: parameter. Best shot is to generate types with name looking like member name.
I think it should just be simple functions:
template
char const* name_at_c(Sequence const& seq); template
char const* name_at(Sequence const& seq); There should be a compile error if Sequence has no named members. Some types of sequences may implement it through a customization point (same scheme that at_c and friends use).
The function argument would not be necessary, wouldn't it? All the
information is available in the type Sequence.
template
On Mon, Jan 25, 2010 at 4:54 AM, joel falcou
name will obviously be char* and you can't have that in a template parameter.
Unless using mpl::string, no? Not sure it's possible to generate mpl::string<'foob','ar'> from "foobar" passed to the macro though. --DD
----- Original Message -----
From: "Dominique Devienne"
On Mon, Jan 25, 2010 at 4:54 AM, joel falcou
wrote: name will obviously be char* and you can't have that in a template parameter.
Unless using mpl::string, no? Not sure it's possible to generate mpl::string<'foob','ar'> from "foobar" passed to the macro though. --DD
Then we could have metafunctions
template
participants (4)
-
Dominique Devienne
-
Hicham Mouline
-
Joel de Guzman
-
joel falcou