it is stated in the standard that an array of const elements has a different type than an array of non-constant elements? Here is my code and output of VC2010 and GCC4.8.0.
Thanks.
#include <iostream> #include <typeinfo> #include <ios> int main(){ int arr_a[] = {1, 2}; int const arr_b[] = {3, 4}; // or const int arr_b[] = {3, 4}; std::cout << typeid(arr_a).name() << "\n"; std::cout << typeid(arr_b).name() << "\n"; std::cout << "Same type: " << std::boolalpha << (typeid(arr_a) == typeid(arr_b)) << ".\n"; } int [2] int const [2] Same type: false. A2_i A2_i Same type: true.
source share