Fixes Sun C++ compiler errors (by Pasi Valminen)

This commit is contained in:
zhanyong.wan
2011-04-12 20:36:11 +00:00
parent fc99b1ad51
commit b8c0e16eeb
3 changed files with 29 additions and 16 deletions

View File

@@ -271,7 +271,14 @@ GTEST_API_ bool ShouldRunTestOnShard(
// the given predicate.
template <class Container, typename Predicate>
inline int CountIf(const Container& c, Predicate predicate) {
return static_cast<int>(std::count_if(c.begin(), c.end(), predicate));
// Implemented as an explicit loop since std::count_if() in libCstd on
// Solaris has a non-standard signature.
int count = 0;
for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {
if (predicate(*it))
++count;
}
return count;
}
// Applies a function/functor to each element in the container.