Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between void and cv void?

I have come across the type "cv void" in the latest draft of the C++ standard (N4606) :

8.3.3 [dcl.mptr], paragraph 3

A pointer to member shall not point to a static member of a class (9.2.3), a member with reference type, or “cv void”.

With a little bit of research, I found "cv void" is a real type, but I have no idea what's the difference compared to the type void. Can you explain it with an example (maybe with a code) ?


EDIT :

  • I sort of expected cv would stand for cv-qualified. My question here is, why do we need to "cv-qualify" the type void?
  • The reason I said "cv void is a real type" is that, the standard actually defined it:

    3.9.1 [basic.fundamental], paragraph 9

    A type cv void is an incomplete type that cannot be completed; such a type has an empty set of values...

like image 266
b1sub Avatar asked Oct 09 '16 17:10

b1sub


1 Answers

"cv void" is not a real type. "cv" here is a shorthand for "possibly cv-qualified", which means "may have a const or a volatile on it".

The passage means that a pointer-to-member may not point to an object of the following types: void, const void, volatile void and const volatile void. It's fairly obvious, since such objects cannot exist in the first place, but I guess it's nice to be clear.

like image 132
Lightness Races in Orbit Avatar answered Oct 26 '22 11:10

Lightness Races in Orbit