I have:
struct foo {
...
std::unique_ptr<Bar> bar; // requires foo to be move-only
foo() { bar = std::make_unique<Bar>(); }
foo(foo&&) = default;
};
typedef boost::multi_index_container<
foo,
boost::multi_index::indexed_by<
boost::multi_index::random_access<>,
boost::multi_index::hashed_unique<
boost::multi_index::composite_key<
foo,
boost::multi_index::member<X,std::string,&X::zoo>,
>
>
>
> MyContainerType;
And two containers of this MyContainerType:
MyContainerType c1, c2;
And at some moment I want to iterate through all c1 elements and add some of them (according to some logics,) to c2. I tried:
for (auto it = c1.begin(); it != c1.end(); ++it) {
if (...some logics... ) {
c2.push_back(std::move(*it));
}
}
But it does not compile, same as many another ways I have tried.