| 1 | #include <cstdio>
|
|---|
| 2 |
|
|---|
| 3 | #include "boost/fusion/include/map.hpp"
|
|---|
| 4 | #include "boost/fusion/include/pair.hpp"
|
|---|
| 5 | #include "boost/fusion/include/at_key.hpp"
|
|---|
| 6 |
|
|---|
| 7 | using namespace boost;
|
|---|
| 8 |
|
|---|
| 9 | class MappedType
|
|---|
| 10 | {
|
|---|
| 11 | public:
|
|---|
| 12 | MappedType() : m_value(1234.0) {}
|
|---|
| 13 |
|
|---|
| 14 | double m_value;
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | class ClassA
|
|---|
| 19 | {
|
|---|
| 20 | public:
|
|---|
| 21 | struct key0;
|
|---|
| 22 | struct key1;
|
|---|
| 23 |
|
|---|
| 24 | void Print() const
|
|---|
| 25 | {
|
|---|
| 26 | printf("MappedType 0 : %g\nMappedType 1 : %g\n",
|
|---|
| 27 | fusion::at_key<key0>(m_map).m_value,
|
|---|
| 28 | fusion::at_key<key1>(m_map).m_value);
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | fusion::map<
|
|---|
| 32 | fusion::pair<key0, MappedType>,
|
|---|
| 33 | fusion::pair<key1, MappedType>
|
|---|
| 34 | > m_map;
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | int main()
|
|---|
| 39 | {
|
|---|
| 40 | ClassA object1;
|
|---|
| 41 | std::pair<int, ClassA> pair0(0, object1);
|
|---|
| 42 | printf("object copy construction (not broken)\n");
|
|---|
| 43 | pair0.second.Print();
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | std::pair<int, ClassA> pair1(1, ClassA());
|
|---|
| 47 | printf("in place construction (broken for c++11)\n");
|
|---|
| 48 | pair1.second.Print();
|
|---|
| 49 |
|
|---|
| 50 | return 0;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|