tuple_element.fail.cpp 953 B

12345678910111213141516171819202122232425262728293031323334
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <tuple>
  10. // template <class... Types> class tuple;
  11. // template <size_t I, class... Types>
  12. // class tuple_element<I, tuple<Types...> >
  13. // {
  14. // public:
  15. // typedef Ti type;
  16. // };
  17. // UNSUPPORTED: c++98, c++03
  18. #include <tuple>
  19. #include <type_traits>
  20. int main()
  21. {
  22. using T = std::tuple<int, long, void*>;
  23. using E1 = typename std::tuple_element<1, T &>::type; // expected-error{{undefined template}}
  24. using E2 = typename std::tuple_element<3, T>::type;
  25. using E3 = typename std::tuple_element<4, T const>::type;
  26. // expected-error@__tuple:* 2 {{static_assert failed}}
  27. }