What type should std :: remove_cv output to a const T array?

What type should std::remove_cv<const int[3]> produce? int[3] or const int[3] ?

const int[3] is the array of 3 const int on the right ?, and does not have a top-level cv determinant. So it should not produce const int[3] ? I think the latest version of gcc / libstdC ++ produces int[3] . This is mistake? Why / why not?

+5
source share
1 answer

N4140 Β§3.9.3 [basic.type.qualifier] / p5, my emphasis is:

Cv qualifiers applied to an array type are attached to the base element type, therefore the designation " cv T ", where T is an array type, refers to an array whose elements are so qualified. An array type whose elements are cv-qualified is also considered cv-qualifications as its elements. [Example:

 typedef char CA[5]; typedef const char CC; CC arr1[5] = { 0 }; const CA arr2 = { 0 }; 

The arr1 and arr2 are "an array of 5 const char " and the type of the array is considered const -qualified. -end example]

See also CWG Release 1059 .

+8
source

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


All Articles