Boost logo

Boost Users :

Subject: Re: [Boost-users] [Iterators] How to implement proxy iterators?
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-02-26 16:24:17


>> Everything works? That would be really nice!
> Well, the only way to be sure is to try it :)
> In this case I am happy and thank you very much for the hint to the
>> Definition :). This helped me a lot.
> Great. Hopefully everything works out. Let us know if it doesn't.

It doesn't :).

Because I was lazy, I just copy pasted the code and added basic
constructor & op= support to the proxy:

class MatrixRowReference:public MatrixRow{
    MatrixRowReference( Matrix& matrix, std::size_t i)

    template<class T>
    const MatrixRowReference& operator=(const T& argument){
        return *this;

    operator Vector(){
        return Vector(*this);

so, pretty straight forward. The iterator is defined as in the previous
mail with the base class:

struct ProxyIterator: public boost::iterator_facade<

The error didn't change. And it is now clear to me, that conversion was
not the Problem in the first place. The quick translated and cleaned error
message reads:

/usr/include/boost/iterator/iterator_facade.hpp: In static element
function »static boost::detail::operator_arrow_result<ValueType,
Reference, Pointer>::type boost::detail::operator_arrow_result<ValueType,
Reference, Pointer>::make(Reference)
[with ValueType = Vector, Reference = MatrixRowReference, Pointer =
Vector*, boost::detail::operator_arrow_result<ValueType, Reference,
Pointer>::type = boost::detail::operator_arrow_proxy<Vector>]«:
[snipping backtrace]
/usr/include/boost/iterator/iterator_facade.hpp:327:49: error: no matching
function for call to »implicit_cast(MatrixRowReference*)«
/usr/include/boost/iterator/iterator_facade.hpp:327:49: note: candidates are:
/usr/include/boost/implicit_cast.hpp:18:10: note: template<class T> T
boost::implicit_cast(typename boost::mpl::identity<T>::type)

looking at the code, it apparently tried to convert MatrixRowReference*
to operator_arrow_proxy<VectorType>

Checking the definition of this proxy, I'm really not sure how this should
work. The compiler might try to call the constructor of
operator_arrow_proxy, but this doesn't seem to be very useful, too:

template <class T>
struct operator_arrow_proxy
    operator_arrow_proxy(T const* px);

im quite sure, that a pointer to my proxy can't be converted to Vector*.

I am still quite certain that the error lies somewhere on my side. So,
what did I do wrong?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at