|
Boost : |
Subject: [boost] [fusion] Getting the adapted structure's member names
From: Andy Venikov (avenikov_at_[hidden])
Date: 2012-01-13 08:35:30
struct alien {
std::string color_;
std::string planet_;
bool benevolent_;
};
BOOST_FUSION_ADAPT_STRUCT(
alien,
(std::string, color_)
(std::string, planet_)
(bool, benevolent_)
)
I know how I can get to the actual member values, i.e. I could check
at<2>(anAlien) to see if I should run away or not.
But what if I wanted to get to the member names? (In this example it would
be "color_", "planet_" and "benevolent_")
It could be very useful for example for serialization that stores not just
values but also the names of the values.
Printing structures to stdout for inspection would be a breeze too.
Since BOOST_FUSION_ADAPT_STRUCT is a macro, surely the member names could
be strigized and stored somewhere.
Thanks,
Andy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk