dbcppp icon indicating copy to clipboard operation
dbcppp copied to clipboard

const iterator

Open mf01 opened this issue 4 years ago • 0 comments

I would suggest to add a const iterator to class Iterable besides to the modifiable iterator. Example for https://github.com/xR3b0rn/dbcppp/blob/master/include/dbcppp/Iterator.h

    template <class Iterator>
    class Iterable
    {
    public:
        Iterable(Iterator begin, Iterator end)
            : _begin(begin)
            , _end(end)
        {}
        Iterator& begin()
        {
            return _begin;
        }
        Iterator& end()
        {
            return _end;
        }


        const Iterator& const_begin() const 
        {
            return _begin;
        }
        const Iterator& const_end() const 
        {
            return _end;
        }
    private:
        Iterator _begin;
        Iterator _end;
    };

Reason: accessing a (const dbcppp::IMessage*)->Signals() with begin()/end(), the compiler ends up with the error that begin()/end() are not marked as const.

mf01 avatar Aug 31 '21 09:08 mf01