[libcxx-commits] [libcxx] [libcxx] Implement `std::constant_wrapper` (PR #191695)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 17 11:06:15 PDT 2026
================
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+
+// constant_wrapper
+
+// [Note 1: The unnamed second template parameter to constant_wrapper is present
+// to aid argument-dependent lookup ([basic.lookup.argdep]) in finding overloads
+// for which constant_wrapper's wrapped value is a suitable argument, but for which
+// the constant_wrapper itself is not. - end note]
+
+#include <cassert>
+#include <concepts>
+#include <type_traits>
+#include <utility>
+
+#include "helpers.h"
+#include "test_macros.h"
+
+namespace MyNamespace {
+struct MyType {
+ int value;
+
+ constexpr MyType(int v = 0) : value(v) {}
+};
+
+constexpr int adl_function(MyType mt) { return mt.value * 2; }
----------------
ldionne wrote:
This does not need to be `constexpr`, which isolates what you're trying to test even a bit more.
https://github.com/llvm/llvm-project/pull/191695
More information about the libcxx-commits
mailing list