Skip to content

Commit

Permalink
gtest: fix std::is_trivially_copy_constructible for GCC 4.8 & 4.9 pro…
Browse files Browse the repository at this point in the history
…perly

`std::is_pod<T>` was deprecated in C++20

original (pre `is_pod`) error on GCC 4.8:
```
/fmt/test/gtest/gtest.h: In static member function 'static constexpr bool testing::internal::MatcherBase<T>::IsInlined()':
/fmt/test/gtest/gtest.h:6512:12: error: 'is_trivially_copy_constructible' was not declared in this scope
            std::is_trivially_copy_constructible<M>::value &&
            ^
/fmt/test/gtest/gtest.h:6512:45: error: expected primary-expression before '>' token
            std::is_trivially_copy_constructible<M>::value &&
                                                  ^
/fmt/test/gtest/gtest.h:6512:46: error: '::value' has not been declared
            std::is_trivially_copy_constructible<M>::value &&
                                                   ^
```
  • Loading branch information
alexezeder authored and vitaut committed Apr 29, 2021
1 parent 3d51ccd commit fd43e4d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/gtest/gtest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -6336,6 +6336,14 @@ struct SharedPayload : SharedPayloadBase {
T value;
};

template <typename T>
using is_trivially_copy_constructible =
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
std::has_trivial_copy_constructor<T>;
#else
std::is_trivially_copy_constructible<T>;
#endif

// An internal class for implementing Matcher<T>, which will derive
// from it. We put functionalities common to all Matcher<T>
// specializations here to avoid code duplication.
Expand Down Expand Up @@ -6509,7 +6517,7 @@ class MatcherBase : private MatcherDescriberInterface {
template <typename M>
static constexpr bool IsInlined() {
return sizeof(M) <= sizeof(Buffer) && alignof(M) <= alignof(Buffer) &&
std::is_pod<M>::value &&
is_trivially_copy_constructible<M>::value &&
std::is_trivially_destructible<M>::value;
}

Expand Down

0 comments on commit fd43e4d

Please sign in to comment.