// { dg-do compile { target c++17 } } #include #include #include using __gnu_test::SimpleAllocator; using value_type = std::multimap::value_type; static_assert(std::is_same_v< decltype(std::multimap{value_type{1, 2.0}, {2, 3.0}, {3, 4.0}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{{value_type{1, 2.0}, {2, 3.0}, {3, 4.0}}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{{value_type{1, 2.0}, {2, 3.0}, {3, 4.0}}, std::less{}, {}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, std::less{}, {}}), std::multimap>); /* This is not deducible, {} could be deduced as _Compare or _Allocator. static_assert(std::is_same_v< decltype(std::multimap{{value_type{1, 2.0}, {2, 3.0}, {3, 4.0}}, {}}), std::multimap>); */ static_assert(std::is_same_v< decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, std::less{}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{{value_type{1, 2.0}, {2, 3.0}, {3, 4.0}}, {}, SimpleAllocator{}}), std::multimap, SimpleAllocator>>); static_assert(std::is_same_v< decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, {}, SimpleAllocator{}}), std::multimap, SimpleAllocator>>); void f() { std::multimap x; static_assert(std::is_same_v< decltype(std::multimap(x.begin(), x.end())), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), std::less{}, std::allocator{}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), std::less{}, {}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap(x.begin(), x.end(), std::less{})), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), {}, std::allocator{}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), {}, SimpleAllocator{}}), std::multimap, SimpleAllocator>>); } using __gnu_test::test_container; using __gnu_test::input_iterator_wrapper; void g() { value_type array[1]; test_container x(array); static_assert(std::is_same_v< decltype(std::multimap(x.begin(), x.end())), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), std::less{}, std::allocator{}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), std::less{}, {}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap(x.begin(), x.end(), std::less{})), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), {}, std::allocator{}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), {}, SimpleAllocator{}}), std::multimap, SimpleAllocator>>); } void h() { std::pair array[1]; test_container, input_iterator_wrapper> x(array); static_assert(std::is_same_v< decltype(std::multimap(x.begin(), x.end())), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), std::less{}, std::allocator{}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), std::less{}, {}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap(x.begin(), x.end(), std::less{})), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), {}, std::allocator{}}), std::multimap>); static_assert(std::is_same_v< decltype(std::multimap{x.begin(), x.end(), {}, SimpleAllocator{}}), std::multimap, SimpleAllocator>>); } template struct require_same; template struct require_same { using type = void; }; template typename require_same::type check_type(U&) { } struct Pool; template struct Alloc : __gnu_test::SimpleAllocator { Alloc(Pool*) { } template Alloc(const Alloc&) { } }; void test_p1518r2() { // P1518R2 - Stop overconstraining allocators in container deduction guides. // This is a C++23 feature but we support it for C++17 too. using PairAlloc = Alloc>; using MMap = std::multimap, PairAlloc>; Pool* p = nullptr; MMap m(p); std::multimap s1(m, p); check_type(s1); std::multimap s2(std::move(m), p); check_type(s2); }