* converting iterator to reverse_iterator
@ 2008-07-25 2:15 Philip
2008-07-25 13:13 ` Eljay Love-Jensen
0 siblings, 1 reply; 2+ messages in thread
From: Philip @ 2008-07-25 2:15 UTC (permalink / raw)
To: gcc-help
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: converting iterator to reverse_iterator
2008-07-25 2:15 converting iterator to reverse_iterator Philip
@ 2008-07-25 13:13 ` Eljay Love-Jensen
0 siblings, 0 replies; 2+ messages in thread
From: Eljay Love-Jensen @ 2008-07-25 13:13 UTC (permalink / raw)
To: Philip, GCC-help
Hi Philip,
The constructor is explicit.
So the first works, since it is explicit.
But the constructor-by-assignment operator doesn't work, since explicit
constructor won't participate in the eliding.
HTH,
--Eljay
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-07-24 23:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-25 2:15 converting iterator to reverse_iterator Philip
2008-07-25 13:13 ` Eljay Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).