|
Boost Users : |
Subject: Re: [Boost-users] Implementing python's enumerate with iterator adaptors
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2012-04-17 09:20:32
On 17 April 2012 13:03, Jens Auer <jensa_at_[hidden]> wrote:
> Â Â bool equal(Enumerator<Iterator, T> const& other) const
>
> Â Â {
>
> Â Â Â Â Â return mPos == mPos;
>
> Â Â }
You likely have a bug above, should read other.mPos.
> My second problem can be reproduced with the following sample program on
> both msvc and g++:
>
>
>
> #include <vector>
>
> #include <iostream>
>
> #include <algorithm>
>
>
>
> void foo()
>
> {
>
> Â Â std::vector<int> v;
>
>
>
> Â Â auto i = Iterator::enumerate(v.begin(), 0, 1);
>
>
>
> Â Â auto y = i->count;
>
> Â Â auto z = i->value;
>
> }
>
> MSVC:
>
> Error     3            error C2664: 'boost::implicit_cast' : cannot
> convert parameter 1 from 'Iterator::Enumerated<T,X> *' to
> 'boost::detail::operator_arrow_proxy<T>'Â Â Â Â Â Â Â Â c:\software
> development\externals\include\boost\iterator\iterator_facade.hpp 326
>
>
>
> G++:
>
> In file included from /usr/include/boost/iterator/iterator_adaptor.hpp:15:0,
>
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â from Enumerate.h:18,
>
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â from Enumerate.cpp:1:
>
> /usr/include/boost/iterator/iterator_facade.hpp: In static member function
> 'static boost::detail::operator_arrow_result<ValueType, Reference,
> Pointer>::type boost::detail::operator_arrow_result<ValueType, Reference,
> Pointer>::make(Reference) [with ValueType = Iterator::Enumerated<int, int>,
> Reference = Iterator::Enumerated<int, int&>, Pointer =
> Iterator::Enumerated<int, int>*,
> boost::detail::operator_arrow_result<ValueType, Reference, Pointer>::type =
> boost::detail::operator_arrow_proxy<Iterator::Enumerated<int, int> >]':
>
> /usr/include/boost/iterator/iterator_facade.hpp:648:49:Â Â instantiated from
> 'boost::iterator_facade<I, V, TC, R, D>::pointer boost::iterator_facade<I,
> V, TC, R, D>::operator->() const [with Derived =
> Iterator::Enumerator<__gnu_cxx::__normal_iterator<int*, std::vector<int> >,
> int>, Value = Iterator::Enumerated<int, int>, CategoryOrTraversal =
> boost::random_access_traversal_tag, Reference = Iterator::Enumerated<int,
> int&>, Difference = int, boost::iterator_facade<I, V, TC, R, D>::pointer =
> boost::detail::operator_arrow_proxy<Iterator::Enumerated<int, int> >]'
>
> Enumerate.cpp:27:14:Â Â instantiated from here
>
> /usr/include/boost/iterator/iterator_facade.hpp:327:49: error: no matching
> function for call to 'implicit_cast(Iterator::Enumerated<int, int&>*)'
It seems you haven't specified what version of Boost you are using.
I suppose you are hitting bug fixed a few months ago.
Try with Boost trunk and the second program should compile.
I haven't checked the first use case issue though.
(FYI, There is no need to post in HTML to public mailing lists. If it
wasn't in HTML,
your code above would have been well formatted.)
Best regards,
-- Mateusz Loskot, http://mateusz.loskot.net
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net