Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

const iterator #84

Open
mf01 opened this issue Aug 31, 2021 · 0 comments
Open

const iterator #84

mf01 opened this issue Aug 31, 2021 · 0 comments

Comments

@mf01
Copy link

mf01 commented Aug 31, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant