summaryrefslogtreecommitdiff
path: root/absl/strings/internal/string_constant.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-02-03 08:46:25 -0800
committerGravatar Derek Mauro <dmauro@google.com>2022-02-03 19:17:29 +0000
commit36db0e4b695756c948dbb45568b43a62ba5883ec (patch)
treef19029c6f2e6b7da0ad196d5c98dbaed8292dc5a /absl/strings/internal/string_constant.h
parent5202173ca7671ebe241cb4d9447dc4b1f2d3ec10 (diff)
Export of internal Abseil changes
-- 4409b08e103d6e7041d18a4d431290cafe3650cf by Derek Mauro <dmauro@google.com>: Workaround NVCC compile error in StringConstant Based on a patch in TensorFlow: https://github.com/tensorflow/tensorflow/blob/da83132aba8d2b6a3c3a9b2e662868eb24f4dd1e/third_party/absl/com_google_absl_fix_mac_and_nvcc_build.patch#L262-L282 Fixes #1105 PiperOrigin-RevId: 426156316 -- 25db16567ffc5400dfaa30b567398ede84729687 by Abseil Team <absl-team@google.com>: Only look for Elf64_Auxinfo on 64-bit FreeBSD. PiperOrigin-RevId: 426132251 -- 2e73c3d9df59b2b769d2b8dca97f0ca5c512c72a by Abseil Team <absl-team@google.com>: Add a problem hint to the error message when dereferencing the end() iterator. PiperOrigin-RevId: 426120394 -- 6befbf89c47963656b9e8151166ab4c8446d4785 by Martijn Vels <mvels@google.com>: Make Cord Btree the default and remove opt out machinery This change makes btree the default Cord format and removes the machinery to opt out. Subsequent changes will remove the 'true' constant evaluation and effectively cleanup all old code and references to CONCAT. PiperOrigin-RevId: 426119728 -- f6a0a664029d61811d90bd484f4eefa0400b5dd4 by Abseil Team <absl-team@google.com>: Mark Notification::HasBeenNotified as ABSL_MUST_USE_RESULT PiperOrigin-RevId: 425927033 GitOrigin-RevId: 4409b08e103d6e7041d18a4d431290cafe3650cf Change-Id: I86f1052c63c13c6486baf4108de2554f162f9c40
Diffstat (limited to 'absl/strings/internal/string_constant.h')
-rw-r--r--absl/strings/internal/string_constant.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/absl/strings/internal/string_constant.h b/absl/strings/internal/string_constant.h
index a11336b7..b358efdd 100644
--- a/absl/strings/internal/string_constant.h
+++ b/absl/strings/internal/string_constant.h
@@ -35,12 +35,18 @@ namespace strings_internal {
// below.
template <typename T>
struct StringConstant {
+ private:
+ static constexpr bool TryConstexprEval(absl::string_view view) {
+ return view.empty() || 2 * view[0] != 1;
+ }
+
+ public:
static constexpr absl::string_view value = T{}();
constexpr absl::string_view operator()() const { return value; }
// Check to be sure `view` points to constant data.
// Otherwise, it can't be constant evaluated.
- static_assert(value.empty() || 2 * value[0] != 1,
+ static_assert(TryConstexprEval(value),
"The input string_view must point to constant data.");
};