problem with deque and string

R

Rich Herrick

I don't know if this is not allowed or there is a bug in g++. If I have the
following definition:

typedef std::deque<const std::string> string_deque;

the compiler complains (in summary) that it cannot overload the allocator.
If I remove "const" thus:

typedef std::deque<std::string> string_deque;

the compilation is successful.

It is me or is it a bug?

Thanks.
 
A

Andrew Koenig

I don't know if this is not allowed or there is a bug in g++. If I have
the
following definition:

typedef std::deque<const std::string> string_deque;

the compiler complains (in summary) that it cannot overload the allocator.
If I remove "const" thus:

typedef std::deque<std::string> string_deque;

the compilation is successful.

It is me or is it a bug?

It's you.

Standard container elements must allow assignment; const values don't.
Ergo, standard container elements can't be const.
 
R

Rich Herrick

Andrew Koenig said:
message

It's you.

Standard container elements must allow assignment; const values don't.
Ergo, standard container elements can't be const.
Thanks a bunch. You learn something new everyday!

Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top