|
Boost Users : |
Subject: [Boost-users] [Boost.Hana] how to merge two or more maps
From: Matthijs Möhlmann (matthijs_at_[hidden])
Date: 2016-08-24 06:02:17
Hi,
I am looking into the documentation of hana to merge two or more maps, say:
#include <boost/hana.hpp>
namespace hana = boost::hana;
int main(int argc, char **argv) {
constexpr auto m1 = hana::make_map(
hana::make_pair("key1"_s, hana::type_c<std::string>),
hana::make_pair("key2"_s, hana::type_c<std::string>)
);
constexpr auto m2 = hana::make_map(
hana::make_pair("key3"_s, hana::type_c<std::string>),
hana::make_pair("key4"_s, hana::type_c<std::string>),
hana::make_pair("key5"_s, hana::type_c<std::string>)
);
// Merge two or more maps?
constexpr auto result = m1 + m2;
return 0;
}
I'm not sure how to do this, probably taking the first map and for every
pair in the subsequent map return an insert? In pseudo code:
constexpr result = hana::insert(hana::insert(m1, pair1), pair2);
Can someone give me some pointers in the right direction?
Regards, Matthijs
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net