1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++03, c++11, c++14 11 12 // Throwing bad_variant_access is supported starting in macosx10.13 13 // XFAIL: with_system_cxx_lib=macosx10.12 && !no-exceptions 14 // XFAIL: with_system_cxx_lib=macosx10.11 && !no-exceptions 15 // XFAIL: with_system_cxx_lib=macosx10.10 && !no-exceptions 16 // XFAIL: with_system_cxx_lib=macosx10.9 && !no-exceptions 17 18 // <variant> 19 // template <class Visitor, class... Variants> 20 // constexpr see below visit(Visitor&& vis, Variants&&... vars); 21 22 #include <variant> 23 24 #include "test_macros.h" 25 26 struct Incomplete; 27 template<class T> struct Holder { T t; }; 28 29 constexpr bool test(bool do_it) 30 { 31 if (do_it) { 32 std::variant<Holder<Incomplete>*, int> v = nullptr; 33 std::visit([](auto){}, v); 34 std::visit([](auto) -> Holder<Incomplete>* { return nullptr; }, v); 35 #if TEST_STD_VER > 17 36 std::visit<void>([](auto){}, v); 37 std::visit<void*>([](auto) -> Holder<Incomplete>* { return nullptr; }, v); 38 #endif 39 } 40 return true; 41 } 42 43 int main(int, char**) 44 { 45 test(true); 46 #if TEST_STD_VER > 17 47 static_assert(test(true)); 48 #endif 49 return 0; 50 } 51