public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100187] New: ranges::search_n helper lambda misses forwarding return type
@ 2021-04-21 16:09 hewillk at gmail dot com
  2021-04-21 16:19 ` [Bug libstdc++/100187] " hewillk at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: hewillk at gmail dot com @ 2021-04-21 16:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100187

            Bug ID: 100187
           Summary: ranges::search_n helper lambda misses forwarding
                    return type
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

ranges_algo.h#L565:

auto __value_comp = [&] <typename _Rp> (_Rp&& __arg) {
  return std::__invoke(__pred, std::forward<_Rp>(__arg), __value);
};

__value_comp misses forwarding the return type (-> decltype(auto)) which made
the following unnecessary failed:

#include <algorithm>

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

int main() {
  Bool b;
  std::vector v{1, 0};
  std::ranges::search_n(v, 1, 1, [&](auto, auto) -> Bool& { return b; });
}

https://godbolt.org/z/zjn8Gz3c5

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-10-13 13:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 16:09 [Bug libstdc++/100187] New: ranges::search_n helper lambda misses forwarding return type hewillk at gmail dot com
2021-04-21 16:19 ` [Bug libstdc++/100187] " hewillk at gmail dot com
2021-04-21 16:44 ` hewillk at gmail dot com
2021-04-22  6:06 ` hewillk at gmail dot com
2021-04-22 19:12 ` [Bug libstdc++/100187] Helper lambda in ranges_algo.h " ppalka at gcc dot gnu.org
2021-04-28  3:23 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:51 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:56 ` cvs-commit at gcc dot gnu.org
2021-10-13 13:58 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).