|  | Home | Libraries | People | FAQ | More | 
BOOST_FUSION_ADAPT_ASSOC_STRUCT is a macro that can be used to generate all the necessary boilerplate to make an arbitrary struct a model of Random Access Sequence and Associative Sequence.
BOOST_FUSION_ADAPT_ASSOC_STRUCT( struct_name, ([member_type0,] member_name0, key_type0) ([member_type1,] member_name1, key_type1) ... )
        The above macro generates the necessary code to adapt struct_name
        as a model of Random
        Access Sequence and Associative
        Sequence. The sequence of ([member_typeN,]
        member_nameN,
        key_typeN)
        tuples declares the type, name and key type of each of the struct members
        that are part of the sequence.
      
When member_typeN is omitted or set to auto, the type is infered with Boost.TypeOf.
        The macro should be used at global scope, and struct_name
        should be the fully namespace qualified name of the struct to be adapted.
      
#include <boost/fusion/adapted/struct/adapt_assoc_struct.hpp> #include <boost/fusion/include/adapt_assoc_struct.hpp>
namespace demo { struct employee { std::string name; int age; }; } namespace keys { struct name; struct age; } // demo::employee is now a Fusion sequence. // It is also an associative sequence with // keys keys::name and keys::age present. BOOST_FUSION_ADAPT_ASSOC_STRUCT( demo::employee, (name, keys::name) (age, keys::age)) // Without BOOST_PP_VARIADICS support : BOOST_FUSION_ADAPT_ASSOC_STRUCT( demo::employee, (auto, name, keys::name), (auto, age, keys::name))