It depends. If you pass in an lvalue when you enter your function (in practice, if you pass in what has a name, to which the address operator belongs and can be applied), the copy constructor of your class will be called.
void foo(vector<char> v) { ... } int bar() { vector<char> myChars = { 'a', 'b', 'c' }; foo(myChars);
If you pass an rvalue (roughly speaking, something that does not have a name and to which the operator address cannot be applied), and the class has a move constructor, then the object will be moved (which don't beware, just like creating " pseudonym, but rather to transfer the guts of the object into a new skeleton, making the previous skeleton useless).
When calling foo() below, the result of make_vector() is the value of r. Therefore, the object returned by it is moved when entering foo() (i.e., the vector constructor of the move will be called):
void foo(vector<char> v); { ... } vector<char> make_vector() { ... }; int bar() { foo(make_vector());
Some STL classes have a move constructor, but do not have a copy constructor, because they are essentially not unique_ptr (for example, unique_ptr ). You will not get a copy of unique_ptr when you pass it to a function.
Even for classes that have a copy constructor, you can still force the move semantics to use the std::move function to change your argument from lvalue to rvalue, but again, which does not create an alias, it simply transfers ownership of the object on the function you are calling. This means that you cannot do anything with the original object, except reassigning it to another value or destroying it.
For example:
void foo(vector<char> v) { ... } vector<char> make_vector() { ... }; int bar() { vector<char> myChars = { 'a', 'b', 'c' }; foo(move(myChars));
If you find that the whole subject of the lvalue and rvalue references and the movement of semantics are unclear, this is very clear. I personally found this tutorial quite useful:
http://thbecker.net/articles/rvalue_references/section_01.html
You can also find information at http://www.isocpp.org or on YouTube (watch seminars by Scott Meyers).