[libcxx-commits] [libcxx] [libc++] Make sure that __desugars_to isn't tripped up by reference_wrapper and cv-refs (PR #132092)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 20 10:34:17 PDT 2025
================
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// Ensure that std::reference_wrapper does not inhibit optimizations based on the
+// std::__desugars_to internal helper.
+
+#include <functional>
+
+static_assert(std::__desugars_to_v<std::__equal_tag, std::equal_to<void>, int, int>,
+ "something is wrong with the test");
+
+// make sure we pass through reference_wrapper
+static_assert(std::__desugars_to_v<std::__equal_tag, std::reference_wrapper<std::equal_to<void> >, int, int>, "");
+static_assert(std::__desugars_to_v<std::__equal_tag, std::reference_wrapper<std::equal_to<void> const>, int, int>, "");
----------------
ldionne wrote:
My thinking was that this test uses `std::equal_to` as a simple example, and we don't want to start checking all of the predicate that we define `__desugars_to` for. We also have `std::__equal`, `std::less`, `ranges::less`, etc.
I actually think that I can decouple this test from `std::equal` by using a dummy type instead, see my next update.
https://github.com/llvm/llvm-project/pull/132092
More information about the libcxx-commits
mailing list