|
Boost Users : |
Subject: Re: [Boost-users] [MultiIndex] As if one iterator
From: Dan Bloomquist (danb_at_[hidden])
Date: 2010-06-07 15:26:24
Joaquin M Lopez Munoz wrote:
> Dan Bloomquist<danb<at> lakeweb.net> writes:
>
> Not sure whether this is what you'r after, but have you considered
> using adobe::any_iterator?
>
> http://stlab.adobe.com/classadobe_1_1any__iterator.html
>
> adobe::any_iterator is a polymorphic iterator wrapper so that
> you can use it to handle at run-time any iterator with the specified
> category (bidirectional, foward, etc.) Kind of like boost::any for
> general objects, but already specialized for the iterator interface.
>
>
Hi Joaquin,
Thank you for the link. I'm on tangents right now but have/will look
over these adobe headers. I have attempted to write my own based on
itereator_facade. I've gotten all the members to work except for
dereferance. I've looked every example I can find where it works, but in
my case some iterator base gets called which is invalid. I've even tried
overriding the arrow operator. In that case I land in operators.hhp with:
template <class T, class P, class B = ::boost::detail::empty_base<T> >
struct dereferenceable : B
{
P operator->() const
{
return &*static_cast<const T&>(*this);
}
};
// next up the stack is, from, multi_index/iter_adaptor.hpp:
typedef typename Base::reference reference;
reference operator*()const
{
return iter_adaptor_access::dereference(final());
}
//Which gets me to this assert:
BOOST_MULTI_INDEX_CHECK_DEREFERENCEABLE_ITERATOR(*this);
Yet my iterator class has all the multi_index buried in code. So I don't
get what got compiled here or how
Best, Dan.
~~~ the iterator class
# include <boost/iterator/iterator_facade.hpp>
class RaOrderRecords;
class RaOrderRecordsIt
:public boost::iterator_facade
<
RaOrderRecordsIt
,ord_record_item const
,boost::bidirectional_traversal_tag
>
{
friend class boost::iterator_core_access;
friend RaOrderRecords;
//container
RaOrderRecords* pParent;
//this index
RsOrderIndex::RecOrderIndex index;
//iterators for proxy
SP_it_adaptor_container spIterators;
public:
//base( ) const { return *this; }
RaOrderRecordsIt( RaOrderRecords* pPrnt,
RsOrderIndex::RecOrderIndex inIdx );
RaOrderRecordsIt( )
:pParent( NULL )//for asserts
{ }
void increment( );// { }
bool equal( const RaOrderRecordsIt& f2 ) const;
ord_record_item const& dereference( ) const;
//ord_record_item& dereference( ) const;
const ord_record_item* operator->( ) const;
RaOrderRecordsIt begin( );
RaOrderRecordsIt end( );
};
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