I have two boost::fusion::map
s that I want to merge in a certain way. Fro the two maps I want to generate a third that has all the keys present in both maps and the values are added if both a present. For example:
#include <boost/fusion/container/map.hpp>
namespace bfn = boost::fusion;
using namespace boost::fusion;
struct x{};
struct y{};
struct z{};
int main(){
auto m = make_map<x, y>(2, 4.3);
auto n = make_map<x>(2.);
auto l = accumulate_merge(m, n); // how this function should look like?
}
After that l
will be equivalent to make_map<x, y>(2 + 2., 4.3)
.
I have no clue where to start. I tried to begin with join
(and the eliminate duplicates but I got complicated pretty fast).
Is there a tool in Boost Fusion that can help me?
(There are lots of subtleties like what to do if for the same key the two corresponding types are different --but still addable--. But any first version will help).
Aucun commentaire:
Enregistrer un commentaire