xref: /llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.verify.cpp (revision dc71a77d33620830020c939bba25ebdfdd1b6194)
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 
9 // <tuple>
10 
11 // template <class... Types> class tuple;
12 
13 // template <size_t I, class... Types>
14 //   const typename tuple_element<I, tuple<Types...> >::type&&
15 //   get(const tuple<Types...>&& t);
16 
17 // UNSUPPORTED: c++03
18 
19 #include <tuple>
20 
cref(T const &)21 template <class T> void cref(T const&) {}
22 template <class T> void cref(T const&&) = delete;
23 
tup4()24 std::tuple<int> const tup4() { return std::make_tuple(4); }
25 
f()26 void f() {
27     // LWG2485: tuple should not open a hole in the type system, get() should
28     // imitate [expr.ref]'s rules for accessing data members
29     {
30         cref(std::get<0>(tup4())); // expected-error {{call to deleted function 'cref'}}
31     }
32 }
33