[libcxx-commits] [libcxx] [libc++][NFC] Remove workaround in a `in_place_t` constructor of `optional` (PR #174306)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 3 19:01:31 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: A. Jiang (frederick-vs-ja)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/174306.diff
1 Files Affected:
- (modified) libcxx/include/optional (+2-8)
``````````diff
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,
``````````
</details>
https://github.com/llvm/llvm-project/pull/174306
More information about the libcxx-commits
mailing list