// { dg-do compile { target c++11 } } #include #include // An allocator that uses __gnu_cxx::_Pointer_adapter as its pointer type. template class std::set, __gnu_test::CustomPointerAlloc>; // Unlike __gnu_cxx::_Pointer_adapter, this fancy pointer supports neither // implicit nor explicit conversions from raw pointers. The constructor from // a raw pointer is explicit and requires a second parameter. The only way for // containers to construct one of these pointers is pointer_traits::pointer_to. template struct Pointer : __gnu_test::PointerBase, T> { using Base = __gnu_test::PointerBase, T>; Pointer() = default; Pointer(std::nullptr_t) : Base() { } explicit Pointer(T* p, int) : Base(p) { } // Allow conversions to const_pointer and to void_pointer template::value && std::is_same::value) || (std::is_void::value && std::is_convertible::value) >::type> Pointer(const Pointer& p) : Base(p.operator->()) { } template static typename std::enable_if::value, Pointer>::type pointer_to(U& t) { return Pointer(std::addressof(t), 1); } }; // A minimal allocator that uses Pointer as its pointer type. template struct Allocator { using value_type = T; using pointer = Pointer; Allocator() = default; template Allocator(const Allocator&) { } pointer allocate(std::size_t n) { return pointer(std::allocator().allocate(n), 1); } void deallocate(pointer p, std::size_t n) { std::allocator().deallocate(p.operator->(), n); } bool operator==(const Allocator&) const { return true; } bool operator!=(const Allocator&) const { return false; } }; template class std::set, Allocator>; #include void test_template_members(__gnu_test::input_container& c) { // Use member functions that are not included in explicit instantiations. std::set, Allocator> s(c.begin(), c.end()); s.emplace(1); s.emplace_hint(s.begin(), 1); s.insert(c.begin(), c.end()); #ifdef __cpp_lib_node_extract std::set, Allocator> s1; s.merge(s1); std::multiset, Allocator> m1; s.merge(m1); #endif #ifdef __cpp_lib_ranges_to_container short arr[2]; __gnu_test::test_input_range r(arr); std::set, Allocator> s2(std::from_range, r); std::set, Allocator> s3(std::from_range, r, Allocator{}); s2.insert_range(r); #endif }