This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/81381] New: std::basic_stringbuf only works with DefaultConstructible allocators
- 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: Mon, 10 Jul 2017 14:16:53 +0000
- Subject: [Bug libstdc++/81381] New: std::basic_stringbuf only works with DefaultConstructible allocators
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81381
Bug ID: 81381
Summary: std::basic_stringbuf only works with
DefaultConstructible allocators
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#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>>;
struct SB : std::basic_stringbuf<char, std::char_traits<char>, Alloc<char>>
{
SB(const string& s) : basic_stringbuf(s) { }
using basic_stringbuf::overflow;
};
int main()
{
string s(Alloc<char>(1));
SB b(s);
b.overflow('a');
assert( b.str().get_allocator() == s.get_allocator() );
}