Il-seob Bae Il-seob Bae - 1 year ago 115
C++ Question

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) ?


  • 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...

Answer Source

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

The passage means that void*, const void*, volatile void* and const volatile void* are impossible in the context of pointers-to-members.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download