std::move()将左值转化为右值

this is summary?

header

std::move()功能强大啊

void ProcessValue(int& i) { 
		std::cout << "LValue processed: " << i << std::endl; 
} 

void ProcessValue(int&& i) { 
		std::cout << "RValue processed: " << i << std::endl; 
} 

int main() { 
  		int a = 0; 
  		ProcessValue(a); 
  		ProcessValue(std::move(a)); 
}

看看在swap的时候,省了3次copy

template <class T> swap(T& a, T& b) 
    { 
        T tmp(std::move(a)); // move a to tmp 
        a = std::move(b);    // move b to a 
        b = std::move(tmp);  // move tmp to b 
 }