Does C++ std::vector passed as function argument decay into a reference or copy?

Viewed 48

When I pass a std::vector into a C++ function, like so:

void myFunc(std::vector<int> myVec)
{
// do something
}

Does the vector myVec get copied or is in reality only a pointer passed? I'm asking from optimization perspective; should I always explicitly pass a pointer to the vector or is there a difference in speed? Assume that I only want to read the data in the function, not manipulate the vector itself.

0 Answers
Related