// { dg-do compile { target c++17 } } #include #include using __gnu_test::SimpleAllocator; static_assert(std::is_same_v< decltype(std::unordered_set{1, 2, 3}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, 0, std::hash{}, std::equal_to{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, 0, std::hash{}, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, {}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, 1, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, 1, SimpleAllocator{}}), std::unordered_set, std::equal_to, SimpleAllocator>>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, 1, std::hash{}, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, 1, std::hash{}, SimpleAllocator{}}), std::unordered_set, std::equal_to, SimpleAllocator>>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, {}, {}, {}, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{{1, 2, 3}, {}, {}, {}, SimpleAllocator{}}), std::unordered_set, std::equal_to, SimpleAllocator>>); void f() { std::unordered_set x; static_assert(std::is_same_v< decltype(std::unordered_set(x.begin(), x.end())), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), {}, std::hash{}, std::equal_to{}, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), {}, std::hash{}, std::equal_to{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), {}, std::hash{}, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set(x.begin(), x.end(), {})), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), 1}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), 1, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), 1, SimpleAllocator{}}), std::unordered_set, std::equal_to, SimpleAllocator>>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), 1, std::hash{}, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), 1, std::hash{}, SimpleAllocator{}}), std::unordered_set, std::equal_to, SimpleAllocator>>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), {}, {}, {}, std::allocator{}}), std::unordered_set>); static_assert(std::is_same_v< decltype(std::unordered_set{x.begin(), x.end(), {}, {}, {}, SimpleAllocator{}}), std::unordered_set, std::equal_to, 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 Hash = std::hash; using Eq = std::equal_to<>; using USet = std::unordered_set>; Pool* p = nullptr; USet s(p); std::unordered_set s1(s, p); check_type(s1); std::unordered_set s2(std::move(s), p); check_type(s2); }