variant_alternative.fail.cpp (1212B)
1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is dual licensed under the MIT and the University of Illinois Open 7 // Source Licenses. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 // UNSUPPORTED: c++98, c++03, c++11, c++14 12 13 // <variant> 14 15 // template <size_t I, class T> struct variant_alternative; // undefined 16 // template <size_t I, class T> struct variant_alternative<I, const T>; 17 // template <size_t I, class T> struct variant_alternative<I, volatile T>; 18 // template <size_t I, class T> struct variant_alternative<I, const volatile T>; 19 // template <size_t I, class T> 20 // using variant_alternative_t = typename variant_alternative<I, T>::type; 21 // 22 // template <size_t I, class... Types> 23 // struct variant_alternative<I, variant<Types...>>; 24 25 #include <memory> 26 #include <type_traits> 27 #include <variant> 28 29 int main() { 30 using V = std::variant<int, void *, const void *, long double>; 31 std::variant_alternative<4, V>::type foo; // expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}} 32 }