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