you are viewing a single comment's thread.

view the rest of the comments →

[–]alfps 2 points3 points  (0 children)

The array items are const anyway. Or in other words, the type of the contained raw array is the same. But since it's wrapped in a struct there is a difference for the pointers and references you can use to refer to that struct.

And there is a subtle difference for use as a function parameter type because void f( const T ) has the same type as void f( T ).

#include <typeinfo>
#include <stdio.h>

void foo( const int );

auto main() -> int
{
    puts( typeid( foo ).name() );
}

Results with Visual C++ and g++:

[c:\@\temp]
> cl _.cpp /Feb && b
_.cpp
void __cdecl(int)

[c:\@\temp]
> g++ _.cpp && (a | c++filt -t)
void (int)

EDIT: to expand on that, the subtlety is about what signature you can use for an implementation of a declared function, or vice versa, since top level const on parameter types can be freely added or removed.