[libcxx-commits] [PATCH] D147560: [libc++] Fix std::optional-related type deduction
Ian McKellar via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 4 14:59:34 PDT 2023
ianloic updated this revision to Diff 510936.
ianloic added a comment.
Reduce test case, address comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147560/new/
https://reviews.llvm.org/D147560
Files:
libcxx/include/optional
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ambigous_constructor.pass.cpp
Index: libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ambigous_constructor.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ambigous_constructor.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// <optional>
+
+#include <optional>
+
+#include "test_macros.h"
+
+struct Bar {
+ int s;
+};
+
+struct Foo {
+ Foo(Bar) {}
+ Foo(std::optional<int>) {}
+};
+
+int main(int, char**) {
+ Foo foo{{.s = 42}};
+
+ return 0;
+}
Index: libcxx/include/optional
===================================================================
--- libcxx/include/optional
+++ libcxx/include/optional
@@ -675,12 +675,11 @@
}
};
template <class _Up>
- using _CheckOptionalArgsCtor = _If<
- _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value &&
- _IsNotSame<__remove_cvref_t<_Up>, optional>::value,
- _CheckOptionalArgsConstructor,
- __check_tuple_constructor_fail
- >;
+ using _CheckOptionalArgsCtor =
+ _If< _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value &&
+ _IsNotSame<__remove_cvref_t<_Up>, optional>::value && _IsNotSame<__remove_cvref_t<_Up>, void>::value,
+ _CheckOptionalArgsConstructor,
+ __check_tuple_constructor_fail >;
template <class _QualUp>
struct _CheckOptionalLikeConstructor {
template <class _Up, class _Opt = optional<_Up>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147560.510936.patch
Type: text/x-patch
Size: 1882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230404/5a2e518b/attachment-0001.bin>
More information about the libcxx-commits
mailing list