I'm having some trouble with this, I have a map of <string, unique_ptr> and an iterator pointing to the pair I want to swap with the first pair in the map.
this code snippet is probably the best chance I have, but it complains about constness
error: no matching function for call to 'swap(std::remove_reference<std::unique_ptr<zge::State>&>::type, std::remove_reference<std::unique_ptr<zge::State>&>::type)'|
error: no matching function for call to 'swap(std::remove_reference<std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, std::unique_ptr<zge::State> > > >::type, std::remove_reference<std::_Rb_tree_iterator<std::pair<const std::basic_string<char>, std::unique_ptr<zge::State> > >&>::type)'|
thanks, I'll have to think of something else, this is the first time I've used a map and the [] operator doesn't act the same way I thought it would so swapping both the key and value doesn't make any sense.
I was trying to implement a state machine for SFML, I did actually get it working two hours ago after hacking away at it for 8 hours (first time using map, first time using abstract base classes, first time using virtual functions, first time using unique_ptr and std::move, first time using enums/class enums, overall I'm pretty happy)
but my non-existent design for it caused it to be useless when you have any more than 1 state, so I'll have another go at it today and tomorrow, and use exceptions instead of class enums, hopefully it will turn out usable.
I realize now there was no reason to swap states around