[libcxx-commits] [libcxx] [libcxx] Implement `std::constant_wrapper` (PR #191695)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 17 12:15:58 PDT 2026


================
@@ -195,6 +195,22 @@ template<class T1, class T2>
 template<class T1, class T2>
     constexpr const T1&& get(const pair<T2, T1>&&) noexcept; // C++14
 
+// [const.wrap.class], class template constant_wrapper
+template<class T>
+  struct cw-fixed-value;                                    // exposition only, since C++26
+
+template<cw-fixed-value X, class = typename decltype(X)::type>
+  struct constant_wrapper;                                  // since C++26
+
+template<class T>
+  concept constexpr-param =                                 // exposition only, since C++26
+    requires { typename constant_wrapper<T::value>; };
----------------
huixie90 wrote:

I think we do in some cases. for example
in `<ranges>`, we have

```
  template<class R>
    concept tiny-range = see below;   // exposition only
```

In `<tuple>`, we have
```
struct ignore-type { // exposition only                             // Since C++26
  constexpr const ignore-type&
    operator=(const auto &) const noexcept
      { return *this; }
};
```

I don't have strong opinion. Happy to remove

https://github.com/llvm/llvm-project/pull/191695


More information about the libcxx-commits mailing list