【发布时间】:2017-01-12 14:59:38
【问题描述】:
但是,我对以下代码进行了修改,但我似乎遗漏了一点。它不会编译。我有两张地图 int -> int。我想生成第三个 int -> int 映射,其中包含两个原件中的所有键值对。 (VS2013) 有人吗?
#include <boost/mpl/map.hpp>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/copy.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/has_key.hpp>
typedef boost::mpl::map <
boost::mpl::pair < boost::mpl::int_<7>, boost::mpl::int_<59> >
>::type Original1;
typedef boost::mpl::map <
boost::mpl::pair < boost::mpl::int_<11>, boost::mpl::int_<61> >
>::type Original2;
typedef boost::mpl::copy <
Original1,
boost::mpl::back_inserter < Original2 >
>::type Merged;
BOOST_MPL_ASSERT((boost::mpl::has_key<Merged, 7>));
int _tmain(int argc, _TCHAR* argv[])
{
const int i = boost::mpl::at<Merged, boost::mpl::int_<7> >::type::value;
return 0;
}
【问题讨论】:
标签: c++ c++11 template-meta-programming boost-mpl