프로그래밍 언어/C++

function-to-pointer conversion에 대해

opencpp 2024. 2. 24. 16:53
반응형

conversion의 설계 개념

C++의 conversion를 정의할 때, 직교하는 3 요소, value category, cv-qualification, data representation를 설계 개념으로 사용한다. conversion를 설계할 때, 요소 중 하나만을 변형하고, 다른 요소를 변형하지 않는다. 어떤 이유로, 예를 들어 하위 호환성을 위해, 설계 개념을 위반할 때는 스펙 문서는 관련된 특수 조항을 별도로 명시한다.

function-to-pointer conversion

value category 요소를 변형하기 위해 설계한 conversion이다. value category 요소만 변경하기 때문에, exact match rank로 분류된다. 또한 일반적으로 cv-qualification이나 data representation를 변경하지 않는다.

function-to-pointer conversion는 function 타입 T의 lvalue category를 T의 pointer prvalue category로 변환한다. 함수 이름 자체는 xvalue categoryprvalue category를 가질 수 없고 lvalue category만 갖는다.

non-static member function를 나타내는 value 자체가 존재하지 않다. 하지만 member function pointer value는 존재한다. non-static member functionnon-static member function를 적용할 수 없다.

결국, function 타입 T에 대한 glvalue-to-prvalue conversion이 바로, function-to-pointer conversion이다.

반응형