로딩
요청 처리 중입니다...

[C++] std::move 총정리 (효율적인 자원 관리)

 [C++] std::move 총정리 (효율적인 자원 관리)

이번에는 C++11에서 추가된 것 중 가장 중요하다고 여겨지는 std::move()에 대해 알아보겠습니다. std::move() 의 개념 이해를 확실하게 하기 위해 하나의 예제와 메모리 그림을 함께 살펴볼께요. #include #include int main() { std::string s1 = "Move Semantics"; std::string s2 = s1; std::string s3 = "Move Semantics"; std::string s4 = std::move(s3); std::cout << "s1: "<< s1 << std::endl; std::cout << "s2: "<< s2 << std::endl; std::cout << "s3: "<< s3 << std::endl; std::cout << "s4: "<< s4 << std::endl; return 0; } 첫번째 줄부터 실행될 때의 메모리 그림을 보면, std::string s...

# move # 장점 # 자원 # 이동 # 성능 # 복사 # 메모리 # swap # semantics # nullptr # 주소