Skip to content

Commit

Permalink
Avoid redundant declaration of static constexpr members in c++17
Browse files Browse the repository at this point in the history
Keep declarations in c++ < 17 using new macro, GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL.

Fixes #4148.

PiperOrigin-RevId: 511510401
Change-Id: I76c3f2fccf07a0978adcbe5f8f0203b9d0c33872
  • Loading branch information
dinord authored and copybara-github committed Feb 22, 2023
1 parent d9a4bbc commit 39a26e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions googletest/include/gtest/internal/gtest-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,10 @@ class HasDebugStringAndShortDebugString {
HasDebugStringType::value && HasShortDebugStringType::value;
};

#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
template <typename T>
constexpr bool HasDebugStringAndShortDebugString<T>::value;
#endif

// When the compiler sees expression IsContainerTest<C>(0), if C is an
// STL-style container class, the first overload of IsContainerTest
Expand Down
5 changes: 5 additions & 0 deletions googletest/include/gtest/internal/gtest-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -2447,4 +2447,9 @@ using Variant = ::std::variant<T...>;
#endif // __has_include
#endif // GTEST_HAS_ABSL

#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L
#define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
#endif

#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_

0 comments on commit 39a26e1

Please sign in to comment.