0

In c++ range-v3 library.

Is it possible to access cursor's (from view_facade) internal data?

class range_t : public ranges::view_facade<range_t>
{
    friend ranges::range_access;

    struct cursor {
        cursor() = default;
        cursor(FlatMultiMap& self, std::size_t index)
            : self(&self)
            , index(index)
        {}

        // other implementation stuff
    private:
        // I want to get this data from outside cursor class
        FlatMultiMap* self;
        std::size_t   index;
    };

    cursor begin_cursor() const
    {
        return { *self, index };
    }
    cursor end_cursor() const
    {
        return { *self, end_index };
    }

    FlatMultiMap* self;
    std::size_t   index;
    std::size_t   end_index;

public:
    range_t() = default;
    range_t(FlatMultiMap& self, std::size_t index, std::size_t end_index)
        : self(&self)
        , index(index)
        , end_index(end_index)
    {}

    template<class I, class S>
    range_t(I iterator, S sentinel)
    {
         // how to do this?
         iterator.self  // Error
    }

};

If no - does range-v3 provide something like https://www.boost.org/doc/libs/1_68_0/libs/iterator/doc/iterator_facade.html ?

tower120
  • 5,007
  • 6
  • 40
  • 88
  • 1
    This sounds like an XY problem. https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem What are you trying to accomplish? (for the record, I don't know the answer to your posed question) – xaxxon Nov 20 '18 at 20:07
  • @xaxxon I want to access cursor's/iterator's data – tower120 Nov 20 '18 at 20:25

1 Answers1

0

To access/expose cursor internal data, one need to use cursor's mixin.

It is now documented https://ericniebler.github.io/range-v3/ at "Create Custom Iterators" section.

tower120
  • 5,007
  • 6
  • 40
  • 88