|
Boost Users : |
Subject: Re: [Boost-users] iterator_facade with incomplete type as Value argument
From: Philipp Moeller (philipp.moeller_at_[hidden])
Date: 2012-02-29 08:23:57
Philipp Moeller <philipp.moeller_at_[hidden]> writes:
> I've tried writing an iterator with iterator_facade that returns itself
> as the result of dereference, but the Value template argument requires a
> complete type because it tries to make a difference between returning by
> value or reference if Value is_pod (as far as I understand).
>
> #include <boost/iterator/iterator_facade.hpp>
>
> class iter
> : public boost::iterator_facade< iter,
> iter,
> boost::forward_traversal_tag >
> {
> public:
> void fancy_non_iterator_member();
> private:
> friend class boost::iterator_core_access;
>
> void increment() { }
>
> bool equal(iter const& other) const { return true; }
>
> iter& dereference() const { return const_cast<Derived&>(static_cast<const Derived&>(*this)); }
> };
>
> Is this the intended behavior of iterator_facade? Is there some
> workaround? Would such an iterator actually be conforming?
There is a mistake in the preceding post. iter::dereference should be
defined as:
iter& dereference() const { return const_cast<iter&>(static_cast<const iter&>(*this)); }
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