https://bugs.llvm.org/show_bug.cgi?id=33727

            Bug ID: 33727
           Summary: std::basic_stringbuf only works with
                    DefaultConstructible allocators
           Product: libc++
           Version: 4.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

This doesn't compile:

#include <memory>
#include <sstream>
#include <cassert>

template<typename T>
struct Alloc : std::allocator<T>
{
  template<typename U> struct rebind { using other = Alloc<U>; };
  Alloc(int id) : id(id) { }
  template<typename U> Alloc(const Alloc<U>& a) : id(a.id) { }
  int id;
};

using string = std::basic_string<char, std::char_traits<char>, Alloc<char>>;
using stringbuf = std::basic_stringbuf<char, std::char_traits<char>,
Alloc<char>>;

int main()
{
  string s(Alloc<char>(1));
  stringbuf b(s);
  assert( b.str().get_allocator() == s.get_allocator() );
}

The basic_stringbuf constructor default-initializes its basic_string member,
which default-initializes its allocator.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to