| 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 | // <variant> |
| 12 | // template <class Visitor, class... Variants> |
| 13 | // constexpr see below visit(Visitor&& vis, Variants&&... vars); |
| 14 | |
| 15 | #include <variant> |
| 16 | |
| 17 | #include "test_macros.h" |
| 18 | |
| 19 | struct Incomplete; |
| 20 | template<class T> struct Holder { T t; }; |
| 21 | |
| 22 | constexpr bool test(bool do_it) |
| 23 | { |
| 24 | if (do_it) { |
| 25 | std::variant<Holder<Incomplete>*, int> v = nullptr; |
| 26 | std::visit([](auto){}, v); |
| 27 | std::visit([](auto) -> Holder<Incomplete>* { return nullptr; }, v); |
| 28 | #if TEST_STD_VER > 17 |
| 29 | std::visit<void>([](auto){}, v); |
| 30 | std::visit<void*>([](auto) -> Holder<Incomplete>* { return nullptr; }, v); |
| 31 | #endif |
| 32 | } |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | int main(int, char**) |
| 37 | { |
| 38 | test(do_it: true); |
| 39 | #if TEST_STD_VER > 17 |
| 40 | static_assert(test(true)); |
| 41 | #endif |
| 42 | return 0; |
| 43 | } |
| 44 | |