No, they aren't equivalent. When you have const some_typedef
, the const
applies to the outermost type of the typedef. So if some_typedef
is a reference type (which in your case it is), then the const
applies to the reference. Since there's no such thing as a const
reference type, the const
gets ignored.
That is, if the element type of your vector is int
, then:
const typename iterator_traits<RandomIterator>::reference
becomesint& const
which is equivalent to justint&
.const typename iterator_traits<RandomIterator>::value_type&
becomesconst int&
.