SlideShare a Scribd company logo
1 of 7
Download to read offline
Effective Modern C++ 스터디
item 29.
이동 연산이 존재하지 않고,
저렴하지 않고, 적용되지 않는다고
가정하라
이데아 게임즈 손진화
이동 의미론이 도움이 되지 않는 경우
• 이동연산이 없다
• 이동이 더 빠르지 않다
• 이동을 사용할 수 없다
• 원본 객체가 왼값이다
이동 연산이 없다
• C++98 에 작성한 코드들은 이동을 지원하지
않을 수도 있다
• 형식 선언 시 복사 연산, 이동 연산, 소멸자를
선언 했을 경우 이동 함수가 자동으로
생성되지 않는다
• 형식의 자료 멤버나 상위 클래스에 이동이
삭제 되어있으면 이동연산이 일어나지
않는다
이동이 더 빠르지 않다
• 주소만 바꿀 수 있는 경우에는 이동이
효율적이다 (ex. vector)
• 객체 자체를 이동해야 할 경우에는 효율이
떨어진다 (ex. array,
작은 문자열 최적화가 적용된 string)
이동을 사용할 수 없다
• 예외 안전성이 보장 된 경우에만 이동연산이
수행되는 경우도 있다
원본 객체가 왼값이다
• 오른값 만이 이동 연산의 원본이 될 수 있는
경우도 있다
n은 미지정 값을
가지게 된다
기억해 둘 사항들
• 이동 연산들이 존재하지 않고, 저렴하지 않고,
적용되지 않을 것이라고 가정하라
• 형식들과 이동 의미론 지원 여부를 미리 알 수
있는 경우에는 그런 가정을 둘 필요가 없다

More Related Content

More from 진화 손

C++20 Concepts library
C++20 Concepts libraryC++20 Concepts library
C++20 Concepts library진화 손
 
C++20 Coroutine
C++20 CoroutineC++20 Coroutine
C++20 Coroutine진화 손
 
C++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rulesC++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rules진화 손
 
C++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rulesC++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rules진화 손
 
C++20 explicit(bool)
C++20 explicit(bool)C++20 explicit(bool)
C++20 explicit(bool)진화 손
 
C++20 std::map::contains
C++20 std::map::containsC++20 std::map::contains
C++20 std::map::contains진화 손
 
C++20 Comparing unordered containers
C++20 Comparing unordered containersC++20 Comparing unordered containers
C++20 Comparing unordered containers진화 손
 
C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]진화 손
 
C++ 20 Lambdas in unevaluated contexts
C++ 20 Lambdas in unevaluated contextsC++ 20 Lambdas in unevaluated contexts
C++ 20 Lambdas in unevaluated contexts진화 손
 
C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>진화 손
 
C++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptrC++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptr진화 손
 
C++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fieldsC++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fields진화 손
 
C++ 20 constexpr for algorithm and utility
C++ 20 constexpr for  algorithm and utilityC++ 20 constexpr for  algorithm and utility
C++ 20 constexpr for algorithm and utility진화 손
 
C++17 init-statements for if and switch
C++17 init-statements for if and switchC++17 init-statements for if and switch
C++17 init-statements for if and switch진화 손
 
C++17 Aggregate classes with base classes
C++17 Aggregate classes with base classesC++17 Aggregate classes with base classes
C++17 Aggregate classes with base classes진화 손
 
C++17 std::byte
C++17 std::byteC++17 std::byte
C++17 std::byte진화 손
 
C++17 Dynamic memory allocation for over-aligned data
C++17 Dynamic memory allocation for over-aligned dataC++17 Dynamic memory allocation for over-aligned data
C++17 Dynamic memory allocation for over-aligned data진화 손
 
C++17 return type of emplace_ functions of some containers changed from void ...
C++17 return type of emplace_ functions of some containers changed from void ...C++17 return type of emplace_ functions of some containers changed from void ...
C++17 return type of emplace_ functions of some containers changed from void ...진화 손
 
C++17 [[fallthrough]] attribute
C++17 [[fallthrough]] attributeC++17 [[fallthrough]] attribute
C++17 [[fallthrough]] attribute진화 손
 

More from 진화 손 (20)

C++20 Concepts library
C++20 Concepts libraryC++20 Concepts library
C++20 Concepts library
 
C++20 Coroutine
C++20 CoroutineC++20 Coroutine
C++20 Coroutine
 
C++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rulesC++ 20 Relaxing the range-for loop customization point finding rules
C++ 20 Relaxing the range-for loop customization point finding rules
 
C++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rulesC++ 20 Relaxing the structured bindings customization point finding rules
C++ 20 Relaxing the structured bindings customization point finding rules
 
C++20 explicit(bool)
C++20 explicit(bool)C++20 explicit(bool)
C++20 explicit(bool)
 
C++20 std::map::contains
C++20 std::map::containsC++20 std::map::contains
C++20 std::map::contains
 
C++20 Comparing unordered containers
C++20 Comparing unordered containersC++20 Comparing unordered containers
C++20 Comparing unordered containers
 
C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]C++20 Attributes [[likely]] and [[unlikely]]
C++20 Attributes [[likely]] and [[unlikely]]
 
C++ 20 Lambdas in unevaluated contexts
C++ 20 Lambdas in unevaluated contextsC++ 20 Lambdas in unevaluated contexts
C++ 20 Lambdas in unevaluated contexts
 
C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>C++20 Library support for operator<=> <compare>
C++20 Library support for operator<=> <compare>
 
C++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptrC++20 Atomic std::shared_ptr and std::weak_ptr
C++20 Atomic std::shared_ptr and std::weak_ptr
 
C++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fieldsC++20 Default member initializers for bit-fields
C++20 Default member initializers for bit-fields
 
C++ 20 constexpr for algorithm and utility
C++ 20 constexpr for  algorithm and utilityC++ 20 constexpr for  algorithm and utility
C++ 20 constexpr for algorithm and utility
 
C++17 init-statements for if and switch
C++17 init-statements for if and switchC++17 init-statements for if and switch
C++17 init-statements for if and switch
 
C++17 Aggregate classes with base classes
C++17 Aggregate classes with base classesC++17 Aggregate classes with base classes
C++17 Aggregate classes with base classes
 
C++17 std::byte
C++17 std::byteC++17 std::byte
C++17 std::byte
 
C++17 not_fn
C++17 not_fnC++17 not_fn
C++17 not_fn
 
C++17 Dynamic memory allocation for over-aligned data
C++17 Dynamic memory allocation for over-aligned dataC++17 Dynamic memory allocation for over-aligned data
C++17 Dynamic memory allocation for over-aligned data
 
C++17 return type of emplace_ functions of some containers changed from void ...
C++17 return type of emplace_ functions of some containers changed from void ...C++17 return type of emplace_ functions of some containers changed from void ...
C++17 return type of emplace_ functions of some containers changed from void ...
 
C++17 [[fallthrough]] attribute
C++17 [[fallthrough]] attributeC++17 [[fallthrough]] attribute
C++17 [[fallthrough]] attribute
 

Effective modern cpp item29

  • 1. Effective Modern C++ 스터디 item 29. 이동 연산이 존재하지 않고, 저렴하지 않고, 적용되지 않는다고 가정하라 이데아 게임즈 손진화
  • 2. 이동 의미론이 도움이 되지 않는 경우 • 이동연산이 없다 • 이동이 더 빠르지 않다 • 이동을 사용할 수 없다 • 원본 객체가 왼값이다
  • 3. 이동 연산이 없다 • C++98 에 작성한 코드들은 이동을 지원하지 않을 수도 있다 • 형식 선언 시 복사 연산, 이동 연산, 소멸자를 선언 했을 경우 이동 함수가 자동으로 생성되지 않는다 • 형식의 자료 멤버나 상위 클래스에 이동이 삭제 되어있으면 이동연산이 일어나지 않는다
  • 4. 이동이 더 빠르지 않다 • 주소만 바꿀 수 있는 경우에는 이동이 효율적이다 (ex. vector) • 객체 자체를 이동해야 할 경우에는 효율이 떨어진다 (ex. array, 작은 문자열 최적화가 적용된 string)
  • 5. 이동을 사용할 수 없다 • 예외 안전성이 보장 된 경우에만 이동연산이 수행되는 경우도 있다
  • 6. 원본 객체가 왼값이다 • 오른값 만이 이동 연산의 원본이 될 수 있는 경우도 있다 n은 미지정 값을 가지게 된다
  • 7. 기억해 둘 사항들 • 이동 연산들이 존재하지 않고, 저렴하지 않고, 적용되지 않을 것이라고 가정하라 • 형식들과 이동 의미론 지원 여부를 미리 알 수 있는 경우에는 그런 가정을 둘 필요가 없다