http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50118
Bug #: 50118 Summary: node-based containers cannot use allocators with explicit constructor template Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: r...@gcc.gnu.org #include <memory> #include <list> #include <set> #include <map> template <class T> struct Alloc : std::allocator<T> { Alloc() { } template<class U> explicit // N.B. explicit ****** Alloc(const Alloc<U>&) { } template<class U> struct rebind { typedef Alloc<U> other; }; }; Alloc<int> a; std::list<int, Alloc<int> > l(a); typedef std::less<int> Cmp; Cmp cmp; std::set<int, Cmp, Alloc<int> > s(cmp, a); std::map<int, int, Cmp, Alloc<int> > m(cmp, a); As far as I can tell there is no requirement in the standard that says Alloc<T> must be implicitly convertible to Alloc<U>, so the node-based containers which rebind allocators from Alloc<value_type> to Alloc<node_type> need to convert explicitly e.g. in stl_list.h _List_base(const allocator_type& __a) - : _M_impl(__a) + : _M_impl(_Node_alloc_type(__a)) { _M_init(); } Alternatively, _List_base::_List_impl could be constructible from the original allocator_type and do the conversion there