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>
145a83710eSEric Fiselier // tuple(allocator_arg_t, const Alloc& a, tuple&&);
155a83710eSEric Fiselier
1631cbe0f2SLouis Dionne // UNSUPPORTED: c++03
170a52cd79SEric Fiselier
185a83710eSEric Fiselier #include <tuple>
195a83710eSEric Fiselier #include <cassert>
205a83710eSEric Fiselier
217fc6a556SMarshall Clow #include "test_macros.h"
22949389c3SMarshall Clow #include "MoveOnly.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 {
305a83710eSEric Fiselier typedef std::tuple<> T;
315a83710eSEric Fiselier T t0;
325a83710eSEric Fiselier T t(std::allocator_arg, A1<int>(), std::move(t0));
335a83710eSEric Fiselier }
345a83710eSEric Fiselier {
355a83710eSEric Fiselier typedef std::tuple<MoveOnly> T;
365a83710eSEric Fiselier T t0(MoveOnly(0));
375a83710eSEric Fiselier T t(std::allocator_arg, A1<int>(), std::move(t0));
385a83710eSEric Fiselier assert(std::get<0>(t) == 0);
395a83710eSEric Fiselier }
405a83710eSEric Fiselier {
415a83710eSEric Fiselier typedef std::tuple<alloc_first> T;
425a83710eSEric Fiselier T t0(1);
435a83710eSEric Fiselier alloc_first::allocator_constructed = false;
445a83710eSEric Fiselier T t(std::allocator_arg, A1<int>(5), std::move(t0));
455a83710eSEric Fiselier assert(alloc_first::allocator_constructed);
465a83710eSEric Fiselier assert(std::get<0>(t) == 1);
475a83710eSEric Fiselier }
485a83710eSEric Fiselier {
495a83710eSEric Fiselier typedef std::tuple<alloc_last> T;
505a83710eSEric Fiselier T t0(1);
515a83710eSEric Fiselier alloc_last::allocator_constructed = false;
525a83710eSEric Fiselier T t(std::allocator_arg, A1<int>(5), std::move(t0));
535a83710eSEric Fiselier assert(alloc_last::allocator_constructed);
545a83710eSEric Fiselier assert(std::get<0>(t) == 1);
555a83710eSEric Fiselier }
565a83710eSEric Fiselier {
575a83710eSEric Fiselier typedef std::tuple<MoveOnly, alloc_first> T;
585a83710eSEric Fiselier T t0(0 ,1);
595a83710eSEric Fiselier alloc_first::allocator_constructed = false;
605a83710eSEric Fiselier T t(std::allocator_arg, A1<int>(5), std::move(t0));
615a83710eSEric Fiselier assert(alloc_first::allocator_constructed);
625a83710eSEric Fiselier assert(std::get<0>(t) == 0);
635a83710eSEric Fiselier assert(std::get<1>(t) == 1);
645a83710eSEric Fiselier }
655a83710eSEric Fiselier {
665a83710eSEric Fiselier typedef std::tuple<MoveOnly, alloc_first, alloc_last> T;
675a83710eSEric Fiselier T t0(1, 2, 3);
685a83710eSEric Fiselier alloc_first::allocator_constructed = false;
695a83710eSEric Fiselier alloc_last::allocator_constructed = false;
705a83710eSEric Fiselier T t(std::allocator_arg, A1<int>(5), std::move(t0));
715a83710eSEric Fiselier assert(alloc_first::allocator_constructed);
725a83710eSEric Fiselier assert(alloc_last::allocator_constructed);
735a83710eSEric Fiselier assert(std::get<0>(t) == 1);
745a83710eSEric Fiselier assert(std::get<1>(t) == 2);
755a83710eSEric Fiselier assert(std::get<2>(t) == 3);
765a83710eSEric Fiselier }
77*a3ab5120SLouis Dionne {
78*a3ab5120SLouis Dionne // Test that we can use a tag derived from allocator_arg_t
79*a3ab5120SLouis Dionne struct DerivedFromAllocatorArgT : std::allocator_arg_t { };
80*a3ab5120SLouis Dionne DerivedFromAllocatorArgT derived;
81*a3ab5120SLouis Dionne std::tuple<int> from(3);
82*a3ab5120SLouis Dionne std::tuple<int> t0(derived, A1<int>(), std::move(from));
83*a3ab5120SLouis Dionne }
842df59c50SJF Bastien
852df59c50SJF Bastien return 0;
865a83710eSEric Fiselier }
87