Avoiding Move

Hi,

Is there a way to make sure that no move constructors or move assignments are ever called? I tried declaring privately and not defining the functions, but then somewhere in my class these seem to be privately called and they cause linker issues if they aren't there. This is happening in a case where I have a map sorted by a custom sorter class where I'm clearing and recreating maps when new sorting info comes in and in other cases where I'm assigning one map to another of the identical sorter but different instance. However, I'm not okay with move assignment because I have to assign multiple maps to the same values, meaning that the source cannot be left in any changed state. Note, I'm using c++11 for the convenience of initializer lists. I can't simply switch back to an older standard without that headache. I'm new to the concepts of move, and it seems to me that there must be a simple way to prevent it in general for cases like mine where the rhs needs to remain in tact.

Thanks,

Sean
1
2
3
4
5
6
7
8
9
10
11
struct A // DefaultConstructible and CopyAssignable, but not MoveAssignable
{
      A() = default ; 
      A( const A& ) = default ;
      A& operator= ( const A& ) = default ;

      A( A&& ) = delete ;
      A& operator= ( A&& ) = delete ;

      std::string str = "hello" ;
};

http://www.stroustrup.com/C++11FAQ.html#default2
Thanks!
Topic archived. No new replies allowed.