This question is a follow-up of A question regarding the implementation of std::add_pointer
Under std::add_pointer
there is the following reference:
Otherwise (if T is a cv- or ref-qualified function type), provides the member typedef type which is the type T.
Based on reading Non-static member functions: const-, volatile-, and ref-qualified member functions, my understanding is that a for a non-static member function with given cv
and/or ref
qualification,
a) the cv
qualification of the function applies to the this
pointer as well, within the scope of the function
b) the ref
qualification of the function does not apply to the this
pointer within the scope of the function
Given this, why is it that std::add_pointer
cannot provide the member typedef
type
T*
in the case of a non-static member function with cv
or ref
qualification?
Per [dcl.ptr]/4:
[ Note: Forming a pointer to reference type is ill-formed; see [dcl.ref]. Forming a function pointer type is ill-formed if the function type has cv-qualifiers or a ref-qualifier; see [dcl.fct]. Since the address of a bit-field cannot be taken, a pointer can never point to a bit-field. — end note ]
The pointer-to-cv-qualified-function type you are imagining is actually nonexistent. Therefore, std::add_pointer
cannot produce such a type :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With