xref: /llvm-project/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp (revision 5cc55fdb57c989b0987faaae7b667cd3459abae1)
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 // <map>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // class multimap
125a83710eSEric Fiselier 
135a83710eSEric Fiselier // multimap(const multimap& m, const allocator_type& a);
145a83710eSEric Fiselier 
155a83710eSEric Fiselier #include <map>
165a83710eSEric Fiselier #include <cassert>
175a83710eSEric Fiselier 
187fc6a556SMarshall Clow #include "test_macros.h"
195a83710eSEric Fiselier #include "../../../test_compare.h"
205a83710eSEric Fiselier #include "test_allocator.h"
215a83710eSEric Fiselier #include "min_allocator.h"
225a83710eSEric Fiselier 
main(int,char **)232df59c50SJF Bastien int main(int, char**)
245a83710eSEric Fiselier {
255a83710eSEric Fiselier     {
265a83710eSEric Fiselier     typedef std::pair<const int, double> V;
275a83710eSEric Fiselier     V ar[] =
285a83710eSEric Fiselier     {
295a83710eSEric Fiselier         V(1, 1),
305a83710eSEric Fiselier         V(1, 1.5),
315a83710eSEric Fiselier         V(1, 2),
325a83710eSEric Fiselier         V(2, 1),
335a83710eSEric Fiselier         V(2, 1.5),
345a83710eSEric Fiselier         V(2, 2),
355a83710eSEric Fiselier         V(3, 1),
365a83710eSEric Fiselier         V(3, 1.5),
375a83710eSEric Fiselier         V(3, 2),
385a83710eSEric Fiselier     };
39*5cc55fdbSArthur O'Dwyer     typedef test_less<int> C;
405a83710eSEric Fiselier     typedef test_allocator<V> A;
415a83710eSEric Fiselier     std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
425a83710eSEric Fiselier     std::multimap<int, double, C, A> m(mo, A(3));
435a83710eSEric Fiselier     assert(m == mo);
445a83710eSEric Fiselier     assert(m.get_allocator() == A(3));
455a83710eSEric Fiselier     assert(m.key_comp() == C(5));
465a83710eSEric Fiselier 
475a83710eSEric Fiselier     assert(mo.get_allocator() == A(7));
485a83710eSEric Fiselier     assert(mo.key_comp() == C(5));
495a83710eSEric Fiselier     }
50f2f2a639SEric Fiselier #if TEST_STD_VER >= 11
515a83710eSEric Fiselier     {
525a83710eSEric Fiselier     typedef std::pair<const int, double> V;
535a83710eSEric Fiselier     V ar[] =
545a83710eSEric Fiselier     {
555a83710eSEric Fiselier         V(1, 1),
565a83710eSEric Fiselier         V(1, 1.5),
575a83710eSEric Fiselier         V(1, 2),
585a83710eSEric Fiselier         V(2, 1),
595a83710eSEric Fiselier         V(2, 1.5),
605a83710eSEric Fiselier         V(2, 2),
615a83710eSEric Fiselier         V(3, 1),
625a83710eSEric Fiselier         V(3, 1.5),
635a83710eSEric Fiselier         V(3, 2),
645a83710eSEric Fiselier     };
65*5cc55fdbSArthur O'Dwyer     typedef test_less<int> C;
665a83710eSEric Fiselier     typedef min_allocator<V> A;
675a83710eSEric Fiselier     std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
685a83710eSEric Fiselier     std::multimap<int, double, C, A> m(mo, A());
695a83710eSEric Fiselier     assert(m == mo);
705a83710eSEric Fiselier     assert(m.get_allocator() == A());
715a83710eSEric Fiselier     assert(m.key_comp() == C(5));
725a83710eSEric Fiselier 
735a83710eSEric Fiselier     assert(mo.get_allocator() == A());
745a83710eSEric Fiselier     assert(mo.key_comp() == C(5));
755a83710eSEric Fiselier     }
762a10c960SMarshall Clow     {
772a10c960SMarshall Clow     typedef std::pair<const int, double> V;
782a10c960SMarshall Clow     V ar[] =
792a10c960SMarshall Clow     {
802a10c960SMarshall Clow         V(1, 1),
812a10c960SMarshall Clow         V(1, 1.5),
822a10c960SMarshall Clow         V(1, 2),
832a10c960SMarshall Clow         V(2, 1),
842a10c960SMarshall Clow         V(2, 1.5),
852a10c960SMarshall Clow         V(2, 2),
862a10c960SMarshall Clow         V(3, 1),
872a10c960SMarshall Clow         V(3, 1.5),
882a10c960SMarshall Clow         V(3, 2),
892a10c960SMarshall Clow     };
90*5cc55fdbSArthur O'Dwyer     typedef test_less<int> C;
912a10c960SMarshall Clow     typedef explicit_allocator<V> A;
922a10c960SMarshall Clow     std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A{});
932a10c960SMarshall Clow     std::multimap<int, double, C, A> m(mo, A{});
942a10c960SMarshall Clow     assert(m == mo);
952a10c960SMarshall Clow     assert(m.get_allocator() == A{});
962a10c960SMarshall Clow     assert(m.key_comp() == C(5));
972a10c960SMarshall Clow 
982a10c960SMarshall Clow     assert(mo.get_allocator() == A{});
992a10c960SMarshall Clow     assert(mo.key_comp() == C(5));
1002a10c960SMarshall Clow     }
1015a83710eSEric Fiselier #endif
1022df59c50SJF Bastien 
1032df59c50SJF Bastien   return 0;
1045a83710eSEric Fiselier }
105