gcc 4.8 const vector<const string>

Jonathan Wakely jwakely.gcc@gmail.com
Fri Apr 5 09:54:00 GMT 2013


On 5 April 2013 10:22, Wood, Tobias wrote:
>
> I have managed to get my main project compiling, but only by removing the const qualifiers when doing the following:
> const vector<const string> c_string_vector { "A", "B", "C" };

This is invalid because it instantiates std::allocator<const
string>and the C++11 Allocator requirements state that the template
argument for an allocator is "any non-const object type."

> This compiles fine with clang, but gcc produces an error message that I can't understand. I have attached a minimal test case and the output of g++ 4.8 on my system. Does anyone have any suggestions as to how to initialise this vector correctly?

Don't.

I plan to add static assertions to std::allocator to improve the error
messages you get (see http://gcc.gnu.org/PR55963) but it still won't
compile.



More information about the Gcc-help mailing list