https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming)
Rule of three (C++ programming) - Wikipedia
The rule of three and rule of five are rules of thumb in C++ for the building of exception-safe code and for formalizing rules on resource management. The rules prescribe how the default members of a class should be used to achieve these goals systematical
en.wikipedia.org
Rule of 3
destuctor, copy contructor, copy assignment operator중 하나라도 구현할거라면 나머지도 정의가 필요하다
Rule of 5
desturctor 정의시 copy constructor/assingment operator, move constructor/assignment operator 도 정의 필요
번외로 AUTOSAR 규칙
Rule A12-0-1 (required, implementation, automated)
If a class declares a copy or move operation, or a destructor, either via “=default”, “=delete”, or via a user-provided declaration, then all others of these five special member functions shall be declared as well.
desturctor, copy/move constructor 정의시 나머지 function 들에 대해서도 정의가 필요하다
결국, 종합적인 이야기로는
소멸자정의시 나머지 생성자, 연산자에 대해서도 정의가 필요하다 라는 뜻..
(Rule of 3 만 만족해야한다면 copy assingment/operator만 정의하면 됨)
'개발 > work' 카테고리의 다른 글
[차량] Can Signal (0) | 2022.09.06 |
---|---|
systemd service Type (0) | 2022.04.18 |
doxygen 환경 구성 (0) | 2022.02.18 |
브라우저 제스쳐 동작용어: 핀치 인/아웃 (0) | 2021.12.09 |
[Linux] core갯수 확인하기 (0) | 2021.12.08 |