get_const_rv.fail.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. // const typename tuple_element<I, tuple<Types...> >::type&&
  12. // get(const tuple<Types...>&& t);
  13. // UNSUPPORTED: c++98, c++03
  14. #include <tuple>
  15. template <class T> void cref(T const&) {}
  16. template <class T> void cref(T const&&) = delete;
  17. std::tuple<int> const tup4() { return std::make_tuple(4); }
  18. int main(int, char**)
  19. {
  20. // LWG2485: tuple should not open a hole in the type system, get() should
  21. // imitate [expr.ref]'s rules for accessing data members
  22. {
  23. cref(std::get<0>(tup4())); // expected-error {{call to deleted function 'cref'}}
  24. }
  25. return 0;
  26. }