I am trying to insert unique_ptr into the boost::bimap, but i am getting the error "call to implicitly deleted copy constructor". I am moving the unique_ptr through std::move and i have move constructor and move assignment operator in my class with noexcept keyword, but the insertion is somehow calling the copy constructor.
#include <utility>
#include <boost/bimap.hpp>
class student
{
int a;
public:
explicit student(int a) : a(a) {}
student(student &&r) noexcept = default;
student &operator=(student &&other) noexcept = default;
};
int main()
{
boost::bimap<int, std::unique_ptr<student>> map;
std::unique_ptr<student> a = std::make_unique<student>(5);
map.insert({4, std::move(a)});
}
Errors:-
In template: call to implicitly-deleted copy constructor of 'typename base_::right_value_type' (aka 'const std::unique_ptr')
In template: call to implicitly-deleted copy constructor of 'typename base_::right_value_type' (aka 'std::unique_ptr')