The reason it does not work as expected is that mpl::plus<int_<1>, mpl::at<Map, key>::type
is mpl::integral_constant<int, 2>
, whereas mpl::int_<2>
is a different type.
A working version:
typedef mpl::map<mpl::pair<key, mpl::integral_c<int, 1>>> Map;
typedef mpl::map<mpl::pair<key, mpl::integral_c<int, 2>>> Map2;
typedef mpl::insert<
mpl::erase_key<Map, key>::type,
mpl::pair<key, mpl::plus<mpl::integral_c<int, 1>, mpl::at<Map, key>::type>::type>
>::type Map3;