summaryrefslogtreecommitdiff
path: root/absl/container
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2022-06-09 07:49:38 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-06-09 07:50:21 -0700
commit9eff97861b88999428d1254f95c83d94a2e95944 (patch)
treec7e8da7cd859195888b7c3349c5b02d157758ed3 /absl/container
parent7383f346c9e33a08ed2132f117b3de6b13eac173 (diff)
Fix C++17 constexpr storage deprecation warnings
This change introduces the symbol ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL to guard redundant declarations of static constexpr data members that are needed prior to C++17. This change also introduces the symbol ABSL_INTERNAL_CPLUSPLUS_LANG, which is supposed to be set to the same value as __cplusplus, except it uses _MSVC_LANG on MSVC so that the value is correct on MSVC. Neither of these new symbols should be used outside of Abseil. Fixes #1191 PiperOrigin-RevId: 453923908 Change-Id: I1316c52c19fa0c168b93cced0c817e4cb7c9c862
Diffstat (limited to 'absl/container')
-rw-r--r--absl/container/fixed_array.h2
-rw-r--r--absl/container/internal/hashtablez_sampler.cc3
-rw-r--r--absl/container/internal/raw_hash_set.cc2
3 files changed, 7 insertions, 0 deletions
diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h
index 839ba0bc..2aefae3b 100644
--- a/absl/container/fixed_array.h
+++ b/absl/container/fixed_array.h
@@ -489,12 +489,14 @@ class FixedArray {
Storage storage_;
};
+#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
template <typename T, size_t N, typename A>
constexpr size_t FixedArray<T, N, A>::kInlineBytesDefault;
template <typename T, size_t N, typename A>
constexpr typename FixedArray<T, N, A>::size_type
FixedArray<T, N, A>::inline_elements;
+#endif
template <typename T, size_t N, typename A>
void FixedArray<T, N, A>::NonEmptyInlinedStorage::AnnotateConstruct(
diff --git a/absl/container/internal/hashtablez_sampler.cc b/absl/container/internal/hashtablez_sampler.cc
index c6036d51..efc1be58 100644
--- a/absl/container/internal/hashtablez_sampler.cc
+++ b/absl/container/internal/hashtablez_sampler.cc
@@ -32,7 +32,10 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace container_internal {
+
+#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
constexpr int HashtablezInfo::kMaxStackDepth;
+#endif
namespace {
ABSL_CONST_INIT std::atomic<bool> g_hashtablez_enabled{
diff --git a/absl/container/internal/raw_hash_set.cc b/absl/container/internal/raw_hash_set.cc
index 61bdb773..c63a2e02 100644
--- a/absl/container/internal/raw_hash_set.cc
+++ b/absl/container/internal/raw_hash_set.cc
@@ -31,7 +31,9 @@ alignas(16) ABSL_CONST_INIT ABSL_DLL const ctrl_t kEmptyGroup[16] = {
ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty,
ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty, ctrl_t::kEmpty};
+#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
constexpr size_t Group::kWidth;
+#endif
// Returns "random" seed.
inline size_t RandomSeed() {