From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17504 invoked by alias); 13 Jan 2013 23:53:32 -0000 Received: (qmail 17447 invoked by uid 55); 13 Jan 2013 23:53:00 -0000 From: "corey at octayn dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/55963] std::vector fails Date: Sun, 13 Jan 2013 23:53:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: corey at octayn dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg01146.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55963 --- Comment #4 from Corey Richardson 2013-01-13 23:52:59 UTC --- A more clear error message would be really useful, the feature itself isn't all that important to me. Thank you for giving this your attention so quickly. On Sun, Jan 13, 2013 at 5:43 PM, redi at gcc dot gnu.org wrote: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55963 > > --- Comment #3 from Jonathan Wakely 2013-01-13 22:43:56 UTC --- > Looks like PJP's comment was from 2008, so I'm not sure what requirements he > means were standardized in 2008. > > Looking further into it, I see that the Allocator requirements in C++11 say an > allocator can only be instantiated with a non-const type, see > http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#274 > > Because vector instantiates allocator that makes it > definitely ill-formed. > > So I think I'm going to add a static_assert to std::allocator that rejects > const types, so the error is at least clear it's intentional not a bug. > > To make it work you could write your own thin wrapper around std::allocator > that prevents instantiating it with const types, something like: > > template > struct allocator > : std::allocator::type> > { > template > struct rebind { typedef allocator other; }; > > typedef T value_type; > > allocator() = default; > > allocator(const allocator&) = default; > > template > allocator(const allocator&) { } > }; > > Then use std::vector>. > > -- > Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email > ------- You are receiving this mail because: ------- > You reported the bug.