[Arm] Fix generating code with UB in NeonEmitter (#121802)
[llvm-project.git] / libcxx / test / std / utilities / variant / variant.visit / robust_against_adl.pass.cpp
blob6f17fa32648d411c8ce58b5f759dca401e6ed4ac
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // <variant>
12 // template <class Visitor, class... Variants>
13 // constexpr see below visit(Visitor&& vis, Variants&&... vars);
15 #include <variant>
17 #include "test_macros.h"
19 struct Incomplete;
20 template<class T> struct Holder { T t; };
22 constexpr bool test(bool do_it)
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
33 return true;
36 int main(int, char**)
38 test(true);
39 #if TEST_STD_VER > 17
40 static_assert(test(true));
41 #endif
42 return 0;