Move semantics & std::move

Hey,

Can anyone tell me when I should use the c++11 move semantics?
Do I actually ever need to write a move constructore / assigment op. myself?

What about Movesemantics for local variable?
1
2
3
4
5
6
7
8
Vector<..> vector_ //class member variable

void MyClass::func()
{
 Object obj;
 //do something with obj
 vector.push_back(std::move(obs));
}


Does this code above work? or is it undefined behavior?

and what about moving objects from vector to vector:
1
2
Vector<Object> vec2; Vector<Object> vec1;
vec1.push_back(std::move(vec2[0]));


Does this work correctly?

Can anyone help me with the move semantics :P ?
Last edited on
Topic archived. No new replies allowed.