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, c++17, c++20, c++23 10 // XFAIL: apple-clang 11 12 // <variant> 13 14 // class variant; 15 // template<class Self, class Visitor> 16 // constexpr decltype(auto) visit(this Self&&, Visitor&&); // since C++26 17 // template<class R, class Self, class Visitor> 18 // constexpr R visit(this Self&&, Visitor&&); // since C++26 19 20 #include <variant> 21 22 #include "test_macros.h" 23 24 struct Incomplete; 25 template <class T> 26 struct Holder { 27 T t; 28 }; 29 30 constexpr bool test(bool do_it) { 31 if (do_it) { 32 std::variant<Holder<Incomplete>*, int> v = nullptr; 33 34 v.visit([](auto) {}); 35 v.visit([](auto) -> Holder<Incomplete>* { return nullptr; }); 36 v.visit<void>([](auto) {}); 37 v.visit<void*>([](auto) -> Holder<Incomplete>* { return nullptr; }); 38 } 39 return true; 40 } 41 42 int main(int, char**) { 43 test(true); 44 static_assert(test(true)); 45 46 return 0; 47 } 48