The value_type
of a std::vector<T>
is T
(§23.3.6.1).
The value of is_same
takes cv qualifiers into account (§20.9.6).
In your case that means checking std::is_same<int, int const>
, which is supposed to fail.
Which in turn means that the behavior you observed is wrong according to the standard. It seems that MSVC is dropping the cv qualifiers for value_type:
std::vector<const int>::value_type val = 5;
val = 10;
This compiles on MSVC2008 but fails with gcc 4.4.
You should probably file a bug report with Microsoft.
Edit: Nawaz's comment above got me thinking. According to this question const int
is indeed not allowed as a a value_type in C++03!
It seems though that it is in C++11.. While it's not explicitly forbidden in C++11 for vectors, it is forbidden for allocators (§17.6.3.5), which in turn makes it illegal for vectors as well.
In any case, MSVC's behavior of silently dropping the const
seems wrong here.