Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load std::multimap<uint32_t, std::unique_ptr<SomeClass>> #19

Closed
svenstaro opened this issue Aug 25, 2013 · 1 comment
Closed

Can't load std::multimap<uint32_t, std::unique_ptr<SomeClass>> #19

svenstaro opened this issue Aug 25, 2013 · 1 comment
Labels
Milestone

Comments

@svenstaro
Copy link

I get this:

/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/bits/stl_pair.h:134:35: error: 
  call to deleted constructor of 'std::unique_ptr<Creature, std::default_delete<Creature> >'
    : first(std::forward<_U1>(__x)), second(__y) { }

The way you guys implement loading from map is by inserting

  std::unique_ptr<Creature, std::default_delete<Creature> > >::pair<unsigned int &, void>' requested here
    hint = map.insert(hint, {key, value} );

which violates std::unique_ptr.

  function has been explicitly marked deleted here
  unique_ptr(const unique_ptr&) = delete;

Probably this also breaks with other containers but I only tested it for std::multimap. I suggest looking into a solution that uses emplace instead of insert.

@AzothAmmo
Copy link
Contributor

Should have a fix for this shortly.

AzothAmmo added a commit that referenced this issue Sep 12, 2013
All containers that used insert during loads (map, unordered_map, set, unordered_set)
now use emplace or emplace_hint and move their loaded values into position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants