Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / variant / variant.get / holds_alternative.pass.cpp
blob9fd38222f8d0c0769621fb78399c646c08034b0a
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>
13 // template <class T, class... Types>
14 // constexpr bool holds_alternative(const variant<Types...>& v) noexcept;
16 #include "test_macros.h"
17 #include <variant>
19 int main(int, char**) {
21 using V = std::variant<int>;
22 constexpr V v;
23 static_assert(std::holds_alternative<int>(v), "");
26 using V = std::variant<int, long>;
27 constexpr V v;
28 static_assert(std::holds_alternative<int>(v), "");
29 static_assert(!std::holds_alternative<long>(v), "");
31 { // noexcept test
32 using V = std::variant<int>;
33 const V v;
34 ASSERT_NOEXCEPT(std::holds_alternative<int>(v));
37 return 0;