• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <variant>
11 // UNSUPPORTED: c++98, c++03, c++11, c++14
12 
13 
14 // template <size_t I, class T> struct variant_alternative; // undefined
15 // template <size_t I, class T> struct variant_alternative<I, const T>;
16 // template <size_t I, class T> struct variant_alternative<I, volatile T>;
17 // template <size_t I, class T> struct variant_alternative<I, const volatile T>;
18 // template <size_t I, class T>
19 //   using variant_alternative_t = typename variant_alternative<I, T>::type;
20 //
21 // template <size_t I, class... Types>
22 //    struct variant_alternative<I, variant<Types...>>;
23 
24 
25 #include <variant>
26 #include <cassert>
27 
28 
main()29 int main()
30 {
31     {
32         typedef std::variant<int, double> T;
33         std::variant_alternative<2, T>::type foo; // expected-note {{requested here}}
34         // expected-error-re@variant:* {{static_assert failed{{( due to requirement '2U[L]{0,2} < sizeof...\(_Types\)')?}} "Index out of bounds in std::variant_alternative<>"}}
35     }
36 }
37