public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/50118] New: node-based containers cannot use allocators with explicit constructor template
@ 2011-08-18 14:38 redi at gcc dot gnu.org
  2011-08-18 15:03 ` [Bug libstdc++/50118] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2011-08-18 14:38 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-29 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18 14:38 [Bug libstdc++/50118] New: node-based containers cannot use allocators with explicit constructor template redi at gcc dot gnu.org
2011-08-18 15:03 ` [Bug libstdc++/50118] " paolo.carlini at oracle dot com
2011-08-29 13:43 ` paolo at gcc dot gnu.org
2011-08-29 13:44 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).