| 1 | #include <boost/fusion/include/adapt_struct.hpp>
|
|---|
| 2 | #include <boost/fusion/include/for_each.hpp>
|
|---|
| 3 | #include <iostream>
|
|---|
| 4 |
|
|---|
| 5 | struct TestThing {
|
|---|
| 6 | int bla;
|
|---|
| 7 | char blabla[10];
|
|---|
| 8 | };
|
|---|
| 9 | BOOST_FUSION_ADAPT_STRUCT(
|
|---|
| 10 | TestThing,
|
|---|
| 11 | bla,
|
|---|
| 12 | blabla
|
|---|
| 13 | );
|
|---|
| 14 |
|
|---|
| 15 | struct FuncThing {
|
|---|
| 16 | void operator() (int& bla) const {
|
|---|
| 17 | std::cout << "Int" << std::endl;
|
|---|
| 18 | }
|
|---|
| 19 | void operator() (const int& bla) const {
|
|---|
| 20 | std::cout << "Const Int" << std::endl;
|
|---|
| 21 | }
|
|---|
| 22 | // should be correct though
|
|---|
| 23 | void operator() (char bla[10]) const {
|
|---|
| 24 | std::cout << "Char [10]" << std::endl;
|
|---|
| 25 | }
|
|---|
| 26 | // Wrong
|
|---|
| 27 | void operator() (const char bla[10]) const {
|
|---|
| 28 | std::cout << "Const Char [10]" << std::endl;
|
|---|
| 29 | }
|
|---|
| 30 | };
|
|---|
| 31 | int main () {
|
|---|
| 32 | TestThing bla;
|
|---|
| 33 | FuncThing f;
|
|---|
| 34 | boost::fusion::for_each(bla, f);
|
|---|
| 35 | return 0;
|
|---|
| 36 | }
|
|---|