llvm-project/libcxx/test/std/utilities/variant/variant.helpers/variant_alternative.verify.cpp
Louis Dionne b82dcb624e [libc++] Move all the remaining .fail.cpp tests to .verify.cpp
I made sure they all had some expected-error output in them. Many of
these tests would be better implemented as a positive test using SFINAE,
but this is beyond the scope of this patch.

Differential Revision: https://reviews.llvm.org/D153980
2023-07-03 09:41:03 -04:00

33 lines
1.2 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14
// <variant>
// template <size_t I, class T> struct variant_alternative; // undefined
// template <size_t I, class T> struct variant_alternative<I, const T>;
// template <size_t I, class T> struct variant_alternative<I, volatile T>;
// template <size_t I, class T> struct variant_alternative<I, const volatile T>;
// template <size_t I, class T>
// using variant_alternative_t = typename variant_alternative<I, T>::type;
//
// template <size_t I, class... Types>
// struct variant_alternative<I, variant<Types...>>;
#include <memory>
#include <type_traits>
#include <variant>
int main(int, char**) {
using V = std::variant<int, void *, const void *, long double>;
std::variant_alternative<4, V>::type foo; // expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
return 0;
}