I want to be able to initialize a class that holds a boost::container::flat_map<std::string, std::unique_ptr<AbstractBaseClass>>
in the constructor. Example:
class MapHolder {
public:
MapHolder(boost::container::flat_map<std::string, std::unique_ptr<AbstractBaseClass>> &&map):
_map(std::move(map)) {}
private:
boost::container::flat_map<std::string, std::unique_ptr<AbstractBaseClass>> _map;
};
MapHolder m({
{"test", std::make_unique<ConcreteDerivedClass>("val")}
});
I keep getting the error that it is trying to copy the unique_ptr
s instead of moving them. Is there any way I can fix this?