This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
converting iterator to reverse_iterator
- From: Philip <snzzbk at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 24 Jul 2008 18:50:04 -0400
- Subject: 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.