brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 6a6e3a9 Raw
61 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++2310 11// <complex>12 13//   template<size_t I, class T>14//     constexpr T& get(complex<T>&) noexcept;15//   template<size_t I, class T>16//     constexpr T&& get(complex<T>&&) noexcept;17//   template<size_t I, class T>18//     constexpr const T& get(const complex<T>&) noexcept;19//   template<size_t I, class T>20//     constexpr const T&& get(const complex<T>&&) noexcept;21 22#include <cassert>23#include <complex>24#include <utility>25 26template <typename T>27void test() {28  using C = std::complex<T>;29 30  // &31  {32    C c{T{27}, T{28}};33    // expected-error-re@*:* 3{{static assertion failed {{.*}}Index value is out of range.}}34    std::get<3>(c);35  }36  // &&37  {38    C c{T{27}, T{28}};39    // expected-error-re@*:* 3 {{static assertion failed {{.*}}Index value is out of range.}}40    std::get<3>(std::move(c));41  }42  // const &43  {44    const C c{T{27}, T{28}};45    // expected-error-re@*:* 3 {{static assertion failed {{.*}}Index value is out of range.}}46    std::get<3>(c);47  }48  // const &&49  {50    const C c{T{27}, T{28}};51    // expected-error-re@*:* 3 {{static assertion failed {{.*}}Index value is out of range.}}52    std::get<3>(std::move(c));53  }54}55 56void test() {57  test<float>();58  test<double>();59  test<long double>();60}61