Skip to content

Commit 39a26e1

Browse files
dinordcopybara-github
authored andcommitted
Avoid redundant declaration of static constexpr members in c++17
Keep declarations in c++ < 17 using new macro, GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL. Fixes #4148. PiperOrigin-RevId: 511510401 Change-Id: I76c3f2fccf07a0978adcbe5f8f0203b9d0c33872
1 parent d9a4bbc commit 39a26e1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

googletest/include/gtest/internal/gtest-internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,10 @@ class HasDebugStringAndShortDebugString {
900900
HasDebugStringType::value && HasShortDebugStringType::value;
901901
};
902902

903+
#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
903904
template <typename T>
904905
constexpr bool HasDebugStringAndShortDebugString<T>::value;
906+
#endif
905907

906908
// When the compiler sees expression IsContainerTest<C>(0), if C is an
907909
// STL-style container class, the first overload of IsContainerTest

googletest/include/gtest/internal/gtest-port.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,4 +2447,9 @@ using Variant = ::std::variant<T...>;
24472447
#endif // __has_include
24482448
#endif // GTEST_HAS_ABSL
24492449

2450+
#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
2451+
GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L
2452+
#define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
2453+
#endif
2454+
24502455
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_

0 commit comments

Comments
 (0)