converting iterator to reverse_iterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux