Topic: vector of const objects
Author: "Robert Stafford" <stafford@bindview.com>
Date: 1999/03/08 Raw View
The compiler/standard library we use will not accept std::vector<const A>
Avec. Is this conforming behavior, or merely an implementation peculiarity?
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Nate Lewis" <nlewis@mindspring.com>
Date: 1999/03/08 Raw View
Robert Stafford wrote in message <7c1049$qq2$1@uuneo.neosoft.com>...
>The compiler/standard library we use will not accept std::vector<const
A>
>Avec. Is this conforming behavior, or merely an implementation
peculiarity?
This is conforming behavior. One of the requirements for using any of
the standard containers (from 23.1/3 in the standard) is:
"The type of objects stored in these components must meet the
requirements of CopyConstructible types, and the additional requirements
of Assignable types."
CopyConstructible is no problem, but const objects aren't Assignable, so
you can't put them in any of the standard collections.
--
Nate Lewis, MCSD
nlewis@mindspring.com
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]