[libcxx-commits] [libcxx] [libc++][NFC] Remove workaround in a `in_place_t` constructor of `optional` (PR #174306)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 3 19:01:00 PST 2026
https://github.com/frederick-vs-ja created https://github.com/llvm/llvm-project/pull/174306
There used to be a bug of Clang on constraint computation that blocked some usages of `optional<NestedClass>`. Workaround for the bug was added by 86af6f5088b16c98e7033a6a5cf3c889c5d95e57.
It's verified that since LLVM 16, the regression test started to compile with Clang with the workaround removed. So we should be able to remove the workaround now.
>From 2861d0f50296d1ce56c708c3d8140f27a60f0f49 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Sun, 4 Jan 2026 10:52:05 +0800
Subject: [PATCH] [libc++][NFC] Remove workaround in a `in_place_t` ctor of
`optional`
There used to be a bug of Clang on constraint computation that blocked
some usages of `optional<NestedClass>`. Workaround for the bug was added
by 86af6f5088b16c98e7033a6a5cf3c889c5d95e57.
It's verified that since LLVM 16, the regression test started to compile
with Clang with the workaround removed. So we should be able to remove
the workaround now.
---
libcxx/include/optional | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/libcxx/include/optional b/libcxx/include/optional
index 568c86556d156..a322887f398c2 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -682,9 +682,6 @@ struct __is_std_optional<optional<_Tp>> : true_type {};
template <class _Tp, class... _Args>
inline constexpr bool __is_constructible_for_optional_v = is_constructible_v<_Tp, _Args...>;
-template <class _Tp, class... _Args>
-struct __is_constructible_for_optional : bool_constant<__is_constructible_for_optional_v<_Tp, _Args...>> {};
-
template <class _Tp, class _Up, class... _Args>
inline constexpr bool __is_constructible_for_optional_initializer_list_v =
is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>;
@@ -895,11 +892,8 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default;
_LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {}
- template <
- class _InPlaceT,
- class... _Args,
- enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>, __is_constructible_for_optional<_Tp, _Args...>>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args)
+ template <class... _Args, enable_if_t<__is_constructible_for_optional_v<_Tp, _Args...>, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, _Args&&... __args)
: __base(in_place, std::forward<_Args>(__args)...) {}
template <class _Up,
More information about the libcxx-commits
mailing list