Thanks to visit codestin.com
Credit goes to github.com

Skip to content

<ranges>: chunk_by_view's helper lambda does not specify return type #2889

@hewillk

Description

@hewillk

STL/stl/inc/ranges

Lines 6258 to 6260 in ef62d3f

const auto _Not_pred = [&_Orig_pred = *_Pred]<class _Ty1, class _Ty2>(_Ty1&& _Left, _Ty2&& _Right) {
return !_STD invoke(_Orig_pred, _STD forward<_Ty1>(_Left), _STD forward<_Ty2>(_Right));
};

STL/stl/inc/ranges

Lines 6272 to 6274 in ef62d3f

const auto _Rev_not_pred = [&_Orig_pred = *_Pred]<class _Ty1, class _Ty2>(_Ty1&& _Left, _Ty2&& _Right) {
return !_STD invoke(_Orig_pred, _STD forward<_Ty2>(_Right), _STD forward<_Ty1>(_Left));
};

This is basically the same problem as #2888.
I don't know how to use MSVC-STL-trunk with Compiler Explorer, but the following code should be rejected incorrectly.

#include <ranges>

struct Bool {
  Bool& operator!();
  Bool() = default;
  Bool(const Bool&) = delete;
  operator bool() { return true; };
};

int main() {
  Bool b;
  int x[] = {42};
  auto r = std::views::iota(0, 5) | std::views::chunk_by([&](auto, auto) -> Bool& { return b; });
  r.begin();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!rangesC++20/23 ranges

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions