//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // UNSUPPORTED: libcpp-no-deduction-guides // template>, // class Pred = equal_to>, // class Allocator = allocator>> // unordered_multimap(InputIterator, InputIterator, typename see below::size_type = see below, // Hash = Hash(), Pred = Pred(), Allocator = Allocator()) // -> unordered_multimap, iter-mapped-type, Hash, Pred, // Allocator>; // // template, // class Pred = equal_to, class Allocator = allocator>> // unordered_multimap(initializer_list>, // typename see below::size_type = see below, Hash = Hash(), // Pred = Pred(), Allocator = Allocator()) // -> unordered_multimap; // // template // unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Allocator) // -> unordered_multimap, iter-mapped-type, // hash>, // equal_to>, Allocator>; // // template // unordered_multimap(InputIterator, InputIterator, Allocator) // -> unordered_multimap, iter-mapped-type, // hash>, // equal_to>, Allocator>; // // template // unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) // -> unordered_multimap, iter-mapped-type, Hash, // equal_to>, Allocator>; // // template // unordered_multimap(initializer_list>, typename see below::size_type, Allocator) // -> unordered_multimap, equal_to, Allocator>; // // template // unordered_multimap(initializer_list>, Allocator) // -> unordered_multimap, equal_to, Allocator>; // // template // unordered_multimap(initializer_list>, typename see below::size_type, Hash, // Allocator) // -> unordered_multimap, Allocator>; #include // is_permutation #include #include // INT_MAX #include #include #include "test_allocator.h" using P = std::pair; using PC = std::pair; int main(int, char**) { const PC expected_m[] = { {1,1}, {1,1}, {2,2}, {3,1}, {INT_MAX,1} }; { const P arr[] = { {1,1}, {2,2}, {1,1}, {INT_MAX,1}, {3,1} }; std::unordered_multimap m(std::begin(arr), std::end(arr)); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { const P arr[] = { {1,1}, {2,2}, {1,1}, {INT_MAX,1}, {3,1} }; std::unordered_multimap m(std::begin(arr), std::end(arr), 42); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { const P arr[] = { {1,1}, {2,2}, {1,1}, {INT_MAX,1}, {3,1} }; std::unordered_multimap m(std::begin(arr), std::end(arr), 42, std::hash()); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { const P arr[] = { {1,1}, {2,2}, {1,1}, {INT_MAX,1}, {3,1} }; std::unordered_multimap m(std::begin(arr), std::end(arr), 42, std::hash(), std::equal_to<>()); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to<>>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { const P arr[] = { {1,1}, {2,2}, {1,1}, {INT_MAX,1}, {3,1} }; std::unordered_multimap m(std::begin(arr), std::end(arr), 42, std::hash(), std::equal_to<>(), test_allocator(0, 41)); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to<>, test_allocator>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 41); } { std::unordered_multimap source; std::unordered_multimap m(source); ASSERT_SAME_TYPE(decltype(m), decltype(source)); assert(m.size() == 0); } { std::unordered_multimap source; std::unordered_multimap m{source}; // braces instead of parens ASSERT_SAME_TYPE(decltype(m), decltype(source)); assert(m.size() == 0); } { std::unordered_multimap, std::equal_to<>, test_allocator> source; test_allocator a(0, 42); std::unordered_multimap m(source, a); ASSERT_SAME_TYPE(decltype(m), decltype(source)); assert(m.get_allocator().get_id() == 42); assert(m.size() == 0); } { std::unordered_multimap, std::equal_to<>, test_allocator> source; test_allocator a(0, 43); std::unordered_multimap m{source, a}; // braces instead of parens ASSERT_SAME_TYPE(decltype(m), decltype(source)); assert(m.get_allocator().get_id() == 43); assert(m.size() == 0); } { std::unordered_multimap m { P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} }; ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { std::unordered_multimap m({ P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} }, 42); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { std::unordered_multimap m({ P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} }, 42, std::hash()); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { std::unordered_multimap m({ P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} }, 42, std::hash(), std::equal_to<>()); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to<>>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } { std::unordered_multimap m({ P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} }, 42, std::hash(), std::equal_to<>(), test_allocator(0, 44)); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to<>, test_allocator>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 44); } { const P arr[] = { {1,1}, {2,2}, {1,1}, {INT_MAX,1}, {3,1} }; std::unordered_multimap m(std::begin(arr), std::end(arr), 42, test_allocator(0, 45)); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to, test_allocator>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 45); } { const P arr[] = { {1,1}, {2,2}, {1,1}, {INT_MAX,1}, {3,1} }; std::unordered_multimap m(std::begin(arr), std::end(arr), 42, std::hash(), test_allocator(0, 46)); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to, test_allocator>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 46); } { std::unordered_multimap m({ P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} }, 42, test_allocator(0, 47)); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to, test_allocator>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 47); } { std::unordered_multimap m({ P{1,1L}, P{2,2L}, P{1,1L}, P{INT_MAX,1L}, P{3,1L} }, 42, std::hash(), test_allocator(0, 48)); ASSERT_SAME_TYPE(decltype(m), std::unordered_multimap, std::equal_to, test_allocator>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 48); } return 0; }