converting iterator to reverse_iterator
Philip
snzzbk@gmail.com
Fri Jul 25 02:15:00 GMT 2008
Why does the following conversion work:
vector<int> v;
vector<int>::reverse_iterator i (v.begin ());
While the following gives an error:
vector<int>::reverse_iterator i = v.begin ();
error: conversion from '__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > >' to non-scalar type
'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*,
std::vector<int, std::allocator<int> > > >' requested
>From what I can see by looking at the C++ standard's description of
copy initialization, the copy constructor should be tried at some
point. (And no, I'm not actually interested in converting v.begin()
but rather an existing iterator).
Thanks.
More information about the Gcc-help
mailing list