What type should std::remove_cv<const int[3]>
produce? int[3]
or const int[3]
?
const int[3]
is an array of 3 const int
right?, and has no top-level cv-qualifier. So shouldn't it produce const int[3]
? Latest version of gcc/libstdc++ is producing int[3]
I think. Is this a bug? Why / why not?
N4140 §3.9.3 [basic.type.qualifier]/p5, emphasis mine:
Cv-qualifiers applied to an array type attach to the underlying element type, so the notation “
cv T
,” whereT
is an array type, refers to an array whose elements are so-qualified. An array type whose elements are cv-qualified is also considered to have the same cv-qualifications as its elements. [ Example:typedef char CA[5]; typedef const char CC; CC arr1[5] = { 0 }; const CA arr2 = { 0 };
The type of both
arr1
andarr2
is “array of 5const char
,” and the array type is considered to beconst
-qualified. —end example ]
See also CWG issue 1059.
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