]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27684_contains_ref_to_incomplete_type.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / utilities / tuple / tuple.tuple / tuple.cnstr / PR27684_contains_ref_to_incomplete_type.pass.cpp
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 //
10 // UNSUPPORTED: c++98, c++03
11
12 // <tuple>
13
14 // template <class... Types> class tuple;
15
16 // template <class Alloc> tuple(allocator_arg_t, Alloc const&)
17
18 // Libc++ has to deduce the 'allocator_arg_t' parameter for this constructor
19 // as 'AllocArgT'. Previously libc++ has tried to support tags derived from
20 // 'allocator_arg_t' by using 'is_base_of<AllocArgT, allocator_arg_t>'.
21 // However this breaks whenever a 2-tuple contains a reference to an incomplete
22 // type as its first parameter. See PR27684.
23
24 #include <tuple>
25 #include <cassert>
26
27 struct IncompleteType;
28 extern IncompleteType inc1;
29 extern IncompleteType inc2;
30 IncompleteType const& cinc1 = inc1;
31 IncompleteType const& cinc2 = inc2;
32
33 int main() {
34     using IT = IncompleteType;
35     { // try calling tuple(Tp const&...)
36         using Tup = std::tuple<const IT&, const IT&>;
37         Tup t(cinc1, cinc2);
38         assert(&std::get<0>(t) == &inc1);
39         assert(&std::get<1>(t) == &inc2);
40     }
41     { // try calling tuple(Up&&...)
42         using Tup = std::tuple<const IT&, const IT&>;
43         Tup t(inc1, inc2);
44         assert(&std::get<0>(t) == &inc1);
45         assert(&std::get<1>(t) == &inc2);
46     }
47 }
48
49 struct IncompleteType {};
50 IncompleteType inc1;
51 IncompleteType inc2;