This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can't invoke a non-const method on objects iterated from a std::set


On Sat, Oct 30, 2004 at 11:20:37AM -0400, Hugues Joly wrote:

> Hi,
>    if I define a set of objects and try to invoke a
> non-const method on each of them while iterating the
> set, I get a compilation error.  The gcc compiler
> complains that I try to invoke a non-constant method
> on a const object.  You can see that in a sample
> program as attachment.

Set iterators are inherently const_iterators, to prevent you from
altering the object, which would invalidate the set's ordering.

i.e. set::iterator is the same type as set::const_iterator and both
point to a const object.

jon

-- 
"A scientific theory should be as simple as possible, but no simpler."
	- Albert Einstein


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]