From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12601 invoked by alias); 13 Jan 2013 22:44:18 -0000 Received: (qmail 12167 invoked by uid 48); 13 Jan 2013 22:43:57 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/55963] std::vector fails Date: Sun, 13 Jan 2013 22:44: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: redi at gcc dot gnu.org 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/msg01144.txt.bz2 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>.