<<<<<<< .working ======= >>>>>>> .merge-right.r57125
Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
<<<<<<< .working

BOOST_FUSION_ADAPT_STRUCT

Description

=======
Description
>>>>>>> .merge-right.r57125

BOOST_FUSION_ADAPT_STRUCT is a macro that can be used to generate all the necessary boilerplate to make an arbitrary struct into a Random Access Sequence.

<<<<<<< .working

Synopsis

=======
Synopsis
>>>>>>> .merge-right.r57125
BOOST_FUSION_ADAPT_STRUCT(
    struct_name,
    (member_type0, member_name0)
    (member_type1, member_name1)
    ...
    )
<<<<<<< .working

Semantics

=======
Semantics
>>>>>>> .merge-right.r57125

The above macro generates the necessary code to adapt struct_name as a model of Random Access Sequence. The sequence of (member_typeN, member_nameN) pairs declare the type and names of each of the struct members that will be part of the sequence.

The macro should be used at global scope, and struct_name should be the fully namespace qualified name of the struct to be converted.

<<<<<<< .working

Header

=======
Header
>>>>>>> .merge-right.r57125
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
<<<<<<< .working

Example

=======
Example
>>>>>>> .merge-right.r57125
namespace demo
{
    struct employee
    {
        std::string name;
        int age;
    };
}

// demo::employee is now a Fusion sequence
BOOST_FUSION_ADAPT_STRUCT(
    demo::employee,
    (std::string, name)
    (int, age))

PrevUpHomeNext