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]

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


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