44 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 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 19struct Incomplete;20template<class T> struct Holder { T t; };21 22constexpr 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 > 1729 std::visit<void>([](auto){}, v);30 std::visit<void*>([](auto) -> Holder<Incomplete>* { return nullptr; }, v);31#endif32 }33 return true;34}35 36int main(int, char**)37{38 test(true);39#if TEST_STD_VER > 1740 static_assert(test(true));41#endif42 return 0;43}44