[libcxx-commits] [PATCH] D109066: [libc++] Implement P1951, default arguments for pair's forwarding constructor

Richard Smith - zygoloid via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 17 13:04:19 PDT 2021


rsmith added a comment.

Another example of valid C++20-and-before code (reduced from real code) that libc++ now rejects after this change:

  void f() {
      const int n = 5;
      [] { std::pair<int, long>({1}, n); };
  }

Here, `n` doesn't need to be captured if we call the `pair(const int&, const long&)` constructor, because the lvalue-to-rvalue conversion happens in the lambda. But if we call the `pair(U&&, V&&)` constructor (deducing `V = int`), then `n` does need to be captured and the build breaks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109066/new/

https://reviews.llvm.org/D109066



More information about the libcxx-commits mailing list