| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03, c++11, c++14 |
| 10 | |
| 11 | // <optional> |
| 12 | |
| 13 | // Regression test for https://github.com/llvm/llvm-project/issues/101960 where a constructor |
| 14 | // of std::optional that should have been private was instead publicly available. |
| 15 | |
| 16 | #include <optional> |
| 17 | #include <type_traits> |
| 18 | |
| 19 | struct NastyConvertible { |
| 20 | template <class T> |
| 21 | operator T() { |
| 22 | return 0; |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | using F = int(int); |
| 27 | |
| 28 | static_assert(!std::is_constructible<std::optional<int>, NastyConvertible, int(int), int>::value); |
| 29 | |