15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <tuple>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template <class... Types> class tuple;
125a83710eSEric Fiselier 
135a83710eSEric Fiselier // template <class Alloc, class U1, class U2>
145a83710eSEric Fiselier //   tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
155a83710eSEric Fiselier 
1631cbe0f2SLouis Dionne // UNSUPPORTED: c++03
170a52cd79SEric Fiselier 
185a83710eSEric Fiselier #include <tuple>
195a83710eSEric Fiselier #include <utility>
205a83710eSEric Fiselier #include <cassert>
215a83710eSEric Fiselier 
227fc6a556SMarshall Clow #include "test_macros.h"
235a83710eSEric Fiselier #include "allocators.h"
245a83710eSEric Fiselier #include "../alloc_first.h"
255a83710eSEric Fiselier #include "../alloc_last.h"
265a83710eSEric Fiselier 
main(int,char **)272df59c50SJF Bastien int main(int, char**)
285a83710eSEric Fiselier {
295a83710eSEric Fiselier     {
30a0d87857SStephan T. Lavavej         typedef std::pair<long, int> T0;
31a0d87857SStephan T. Lavavej         typedef std::tuple<long long, double> T1;
325a83710eSEric Fiselier         T0 t0(2, 3);
335a83710eSEric Fiselier         T1 t1(std::allocator_arg, A1<int>(5), t0);
345a83710eSEric Fiselier         assert(std::get<0>(t1) == 2);
355a83710eSEric Fiselier         assert(std::get<1>(t1) == 3);
365a83710eSEric Fiselier     }
375a83710eSEric Fiselier     {
385a83710eSEric Fiselier         typedef std::pair<int, int> T0;
395a83710eSEric Fiselier         typedef std::tuple<alloc_first, double> T1;
405a83710eSEric Fiselier         T0 t0(2, 3);
415a83710eSEric Fiselier         alloc_first::allocator_constructed = false;
425a83710eSEric Fiselier         T1 t1(std::allocator_arg, A1<int>(5), t0);
435a83710eSEric Fiselier         assert(alloc_first::allocator_constructed);
445a83710eSEric Fiselier         assert(std::get<0>(t1) == 2);
455a83710eSEric Fiselier         assert(std::get<1>(t1) == 3);
465a83710eSEric Fiselier     }
475a83710eSEric Fiselier     {
485a83710eSEric Fiselier         typedef std::pair<int, int> T0;
495a83710eSEric Fiselier         typedef std::tuple<alloc_first, alloc_last> T1;
505a83710eSEric Fiselier         T0 t0(2, 3);
515a83710eSEric Fiselier         alloc_first::allocator_constructed = false;
525a83710eSEric Fiselier         alloc_last::allocator_constructed = false;
535a83710eSEric Fiselier         T1 t1(std::allocator_arg, A1<int>(5), t0);
545a83710eSEric Fiselier         assert(alloc_first::allocator_constructed);
555a83710eSEric Fiselier         assert(alloc_last::allocator_constructed);
565a83710eSEric Fiselier         assert(std::get<0>(t1) == 2);
575a83710eSEric Fiselier         assert(std::get<1>(t1) == 3);
585a83710eSEric Fiselier     }
59*a3ab5120SLouis Dionne     {
60*a3ab5120SLouis Dionne         // Test that we can use a tag derived from allocator_arg_t
61*a3ab5120SLouis Dionne         struct DerivedFromAllocatorArgT : std::allocator_arg_t { };
62*a3ab5120SLouis Dionne         DerivedFromAllocatorArgT derived;
63*a3ab5120SLouis Dionne         std::pair<int, int> p(1, 2);
64*a3ab5120SLouis Dionne         std::tuple<int, int> t(derived, A1<int>(), p);
65*a3ab5120SLouis Dionne     }
662df59c50SJF Bastien 
672df59c50SJF Bastien     return 0;
685a83710eSEric Fiselier }
69