This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
parallel equal not parallel
- From: François Dumont <francois dot cppdevs at free dot fr>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 04 Nov 2010 21:48:56 +0100
- Subject: parallel equal not parallel
Hi
I noticed a weird thing in parallel mode code when working on a
patch some weeks ago and I finally take time to report it here. I cannot
build the lib for the moment so I prefer not to submit a patch, if you
confirm the problem I will submit a patch if no one else wants to do so
before I.
Here is the parallel equal implementation in
include/parallel/algobase.h:
template<typename _IIter1, typename _IIter2>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
{
return _GLIBCXX_STD_P::mismatch(__begin1, __end1, __begin2).first
== __end1;
}
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_Predicate __pred)
{
return _GLIBCXX_STD_P::mismatch(__begin1, __end1, __begin2,
__pred).first
== __end1;
}
So it uses the normal mismatch algo, IMO it should be:
template<typename _IIter1, typename _IIter2>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2)
{
return mismatch(__begin1, __end1, __begin2).first == __end1;
}
template<typename _IIter1, typename _IIter2, typename _Predicate>
inline bool
equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2,
_Predicate __pred)
{
return mismatch(__begin1, __end1, __begin2, __pred).first == __end1;
}
Agree ?
François