This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

converting iterator to reverse_iterator


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]