What is the difference between void and cv void?

I met the type “cv void” in the last draft of the C ++ standard (N4606):

8.3.3 [dcl.mptr], clause 3

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

With a bit of research, I found that "cv void" is a real type , but I don't know what the difference is with a void type . Can you explain this with an example (possibly with code)?


EDIT :

  • I kind of expected cv to be behind the cv qualification. My question here is why do we need cv-qualify like void?
  • The reason I said “cv void is the real type” is because the standard actually defined it:

    3.9.1 [basic.fundamental], clause 9

    The cv void type is an incomplete type that cannot be completed; this type has an empty set of values ​​...

+4
source share
4 answers

"cv void" is not a real type. "cv" here is an abbreviation for "maybe cv-qualified", which means "may have constor volatileon it."

, - : void, const void, volatile void const volatile void. , , , , , .

+4

"" void cv-. , , , .

: void cv-, cv- void.

+4

"cv void" void, const - volatile -qualified. void .

- - , - ( ).
, - ...

+2

"cv -qualify" void?

cv- . , memcpy :

void* memcpy( void* dest, const void* src, std::size_t count );

src const void, , src, . const:

const POD pod{...};
POD new_pod;
memcpy(&new_pod, &pod, sizeof(pod)); 
+1

Source: https://habr.com/ru/post/1657212/


All Articles