Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / variant / variant.helpers / variant_size.pass.cpp
blob1ee0c324d7b874f7044d2872314626ee60603275
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> struct variant_size; // undefined
14 // template <class T> struct variant_size<const T>;
15 // template <class T> struct variant_size<volatile T>;
16 // template <class T> struct variant_size<const volatile T>;
17 // template <class T> constexpr size_t variant_size_v
18 // = variant_size<T>::value;
20 #include <memory>
21 #include <type_traits>
22 #include <variant>
24 #include "test_macros.h"
26 template <class V, std::size_t E> void test() {
27 static_assert(std::variant_size<V>::value == E, "");
28 static_assert(std::variant_size<const V>::value == E, "");
29 static_assert(std::variant_size<volatile V>::value == E, "");
30 static_assert(std::variant_size<const volatile V>::value == E, "");
31 static_assert(std::variant_size_v<V> == E, "");
32 static_assert(std::variant_size_v<const V> == E, "");
33 static_assert(std::variant_size_v<volatile V> == E, "");
34 static_assert(std::variant_size_v<const volatile V> == E, "");
35 static_assert(std::is_base_of<std::integral_constant<std::size_t, E>,
36 std::variant_size<V>>::value,
37 "");
40 int main(int, char**) {
41 test<std::variant<>, 0>();
42 test<std::variant<void *>, 1>();
43 test<std::variant<long, long, void *, double>, 4>();
45 return 0;