I'm doing this:
const int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
const auto foo = cbegin(arr);
const typename iterator_traits<decltype(foo)>::value_type bar = 1;
I would have expected bar to have the type int. But instead I'm getting an error:
error C2039:
value_type: is not a member ofstd::iterator_traits<_Ty *const >
Is this a problem with the const do I need to strip that or something?
Indeed the
constis problematic, you do basically:You might fix it by changing it to
You might use
std::decayorstd::remove_cvfor that:(or drop
constfromfooif relevant).