ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.11k stars 440 forks source link

Ranges do not work with C++17 end sentinels #1626

Closed dchansen closed 3 years ago

dchansen commented 3 years ago

In c++17, end() is allowed to return a sentinel which must be equality comparable to the iterator returned by begin(). This is not accurately modelled by range-v3, and such a class does not meet the range concept when compiled under C++17. Note that it works as expected under C++20.

Godbolt link

dvirtz commented 3 years ago

you're missing the reverse order comparators: https://godbolt.org/z/c9bYGEx77

On Fri, 14 May 2021 at 11:34, David Christoffer Hansen < @.***> wrote:

In c++17, end() is allowed to return a sentinel which must be equality comparable to the iterator returned by begin(). This is not accurately modelled by range-v3, and such a class does not meet the range concept when compiled under C++17. Note that it works as expected under C++20.

Godbolt link https://godbolt.org/z/n965bE9zd

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ericniebler/range-v3/issues/1626, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2ORDJLEKAPHENHJS7OJCDTNTOCBANCNFSM444AUH2Q .

dchansen commented 3 years ago

You're absolutely right. Why aren't they needed in c++20?

dvirtz commented 3 years ago

The compiler now generates them for you. See https://brevzin.github.io/c++/2019/07/28/comparisons-cpp20/#reversing-primary-operators

On Fri, 14 May 2021, 15:34 David Christoffer Hansen, < @.***> wrote:

Closed #1626 https://github.com/ericniebler/range-v3/issues/1626.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ericniebler/range-v3/issues/1626#event-4746788502, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2ORDKPK52YJKWSO5K352DTNUKD3ANCNFSM444AUH2Q .