44 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> struct tuple_element;14 15#include <cassert>16#include <complex>17#include <concepts>18 19template <std::size_t I, typename C>20concept HasTupleElement = requires { std::tuple_element<I, C>{}; };21 22struct SomeObject {};23 24static_assert(!HasTupleElement<0, SomeObject>);25static_assert(!HasTupleElement<1, SomeObject>);26static_assert(!HasTupleElement<3, SomeObject>);27 28template <typename T>29void test() {30 using C = std::complex<T>;31 32 static_assert(HasTupleElement<0, C>);33 static_assert(HasTupleElement<1, C>);34 35 static_assert(std::same_as<typename std::tuple_element<0, C>::type, T>);36 static_assert(std::same_as<typename std::tuple_element<1, C>::type, T>);37}38 39void test() {40 test<float>();41 test<double>();42 test<long double>();43}44