I have the following code:
// header
void Method1(const bool& b, std::vector<int>&& v);
bool Method2();
bool CMyClass::Method1()
{
std::vector<int> v{ 1, 2, 3 };
TRACE("%d\n", v.size());
Method2(true, std::move(v));
TRACE("%d\n", v.size());
return true;
}
void CMyClass::Method2(const bool& b, std::vector<int>&& v)
{
TRACE("%d\n", v.size());
}
Outcome:
3
3
3
Seems v is copied, if so, why not moved?