tuple_element.fail.cpp 980 B

12345678910111213141516171819202122232425262728293031323334
  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-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <tuple>
  9. // template <class... Types> class tuple;
  10. // template <size_t I, class... Types>
  11. // struct tuple_element<I, tuple<Types...> >
  12. // {
  13. // typedef Ti type;
  14. // };
  15. // UNSUPPORTED: c++98, c++03
  16. #include <tuple>
  17. #include <type_traits>
  18. int main(int, char**)
  19. {
  20. using T = std::tuple<int, long, void*>;
  21. using E1 = typename std::tuple_element<1, T &>::type; // expected-error{{undefined template}}
  22. using E2 = typename std::tuple_element<3, T>::type;
  23. using E3 = typename std::tuple_element<4, T const>::type;
  24. // expected-error@__tuple:* 2 {{static_assert failed}}
  25. return 0;
  26. }