This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/50118] New: node-based containers cannot use allocators with explicit constructor template
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 18 Aug 2011 14:34:16 +0000
- Subject: [Bug libstdc++/50118] New: node-based containers cannot use allocators with explicit constructor template
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: redi@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