conversion의 설계 개념
C++의 conversion를 정의할 때, 직교하는 3 요소, value category
, cv-qualification
, data representation
를 설계 개념으로 사용한다. conversion를 설계할 때, 요소 중 하나만을 변형하고, 다른 요소를 변형하지 않는다. 어떤 이유로, 예를 들어 하위 호환성을 위해, 설계 개념을 위반할 때는 관련된 특수 조항을 스펙 문서에 별도로 명시한다.
pointer conversions
data representation
요소를 변형하기 위해 설계한 conversion이다. data representation
를 변경하기 때문에, conversion rank
로 분류된다. 또한 일반적으로 value category
이나 cv-qualification
를 변경하지 않는다.
pointer conversions
는 prvalue category
에서 prvalue category
로 변환을 정의한다.
0 value
를 갖는 integer literal type
또는 std::nullptr_t type
의 prvalue category
를 null pointer constant
라고 한다.
null pointer constant
를 type T
의 pointer
로 변경할 수 있다. conversion 결과는 T type
의 null pointer value
를 갖고, T 타입의 다른 pointer value과 구별된다. 같은 type
의 두 null pointer value
는 compare equal
하다. null pointer conversion
에서 T type
의 cv-qualified null pointer conversion
로 변환은 pointer conversion
후 qualification conversion
를 적용한 변환이 아닌 단일 변환이다. 이와 같은 conversion를 null pointer conversion
이라고 부른다.
integer literal type
는 std::nullptr_t type
의 prvalue category
로 변경할 수 있다.
object type T
에 대해, pointer to cv T type
의 prvalue category를 pointer to cv void type
의 prvalue category로 변경할 수 있다. 이 변환으로 pointer value
자체는 변경되지 않는다.
B
가 D
의 base class
이고, D
가 complete type
인 경우에 대해, pointer to cv D type
의 prvalue category에서 pointer to cv B type
의 prvalue category로 변경할 수 있다. D
를 통해 B
를 접근할 수 없거나 base class
가 애매하면, 컴파일 오류다. 변환 결과는 derived class object
의 base class subobject
에 대한 pointer다. null pointer value
는 목적 타입의 null pointer value
로 변경할 수 있다.
'프로그래밍 언어 > C++' 카테고리의 다른 글
floating-integral conversion에 대해 (0) | 2024.03.01 |
---|---|
floating-point conversion에 대해 (0) | 2024.02.29 |
integral conversion에 대해 (0) | 2024.02.29 |
floating-point promotion conversion에 대해 (0) | 2024.02.28 |
integral promotion conversion에 대해 (0) | 2024.02.26 |