[libcxx-commits] [libcxx] [libc++] P2770R0: "Stashing stashing iterators for proper flattening" (PR #66033)
Jakub Mazurkiewicz via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 12 12:27:44 PDT 2023
================
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <ranges>
+
+// template<class T>
+// constexpr T& as-lvalue(T&& t) { // exposition only
+
+#include <ranges>
+
+#include <concepts>
+#include <utility>
+
+constexpr bool test() {
+ // Check glvalue
+ {
+ int lvalue{};
+ [[maybe_unused]] std::same_as<int&> decltype(auto) check = std::ranges::__as_lvalue(lvalue);
+ }
+
+ // Check prvalue (reference is dangling)
+ {
+ [[maybe_unused]] std::same_as<int&> decltype(auto) check = std::ranges::__as_lvalue(0);
----------------
JMazurkiewicz wrote:
The *`as-lvalue`* function is used by P2770 to fix joining ranges of xvalues (rvalue references), see [LWG-3791](https://cplusplus.github.io/LWG/issue3791) and example: https://godbolt.org/z/Ev17W3b5W.
https://github.com/llvm/llvm-project/pull/66033
More information about the libcxx-commits
mailing list