我是融合新手。是否可以在融合图中嵌套融合图?如何在下面的示例中编写解析为B的代码?
#include <boost/asio.hpp>
#include <boost/fusion/container/map.hpp>
#include <boost/unordered_map.hpp>
struct A
{
};
struct B
{
};
int main()
{
boost::fusion::map<
boost::fusion::pair<
A,
boost::fusion::map<boost::fusion::pair<unsigned int, B>>
>
> map_;
B b = boost::fusion::at_key<unsigned int>((boost::fusion::at_key<A>(map_)); //compile error
}
答案 0 :(得分:3)
除了语法错误(一个额外的括号)之外,你只是缺少一些#include
。这对我来说很好:
#include <boost/fusion/include/at_key.hpp>
#include <boost/fusion/include/map.hpp>
#include <boost/fusion/include/pair.hpp>
struct A { };
struct B { };
int main()
{
boost::fusion::map<
boost::fusion::pair<
A,
boost::fusion::map<boost::fusion::pair<unsigned int, B>>
>
> map_;
B b = boost::fusion::at_key<unsigned int>(boost::fusion::at_key<A>(map_));
}