This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
std::equal bombs if the
- From: "Smith-Rowland, Edward M" <ESmith-rowland at alionscience dot com>
- To: <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 26 Aug 2008 12:33:53 -0400
- Subject: std::equal bombs if the
Hi,
I'm working on an implementation of std::forward_list and bumped into something while testing equality of containers:
bool eq = std::equal(firsst1, lasst1, firsst2);
this will bomb if the number of elements in [firsst1, lasst1)
is greater than in [firsst2, firsst2 + distance(firsst1, lasst1)).
The standard seemed to me to be quiet on this but mightn't it be a good idea to watch out that lasst2 doesn't hit the end() of the second list?
Maybe the powers that be didn't want the time overhead of the check?
Is this the way it's supposed to be or is it a bug?
The whole issue turned up for me because forward_list doesn't have size() so I wound up having to walk through and watch out for end() in both lists. The other containers check size() of the two containers.
Thanks,
Ed Smith-Rowland