diff options
author | Abseil Team <absl-team@google.com> | 2024-01-19 10:29:06 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-01-19 10:29:59 -0800 |
commit | 2be67701e7a33b45d322064349827e1155953338 (patch) | |
tree | 8978f3691b7c894868da070da6f19ef2f018bc84 /absl | |
parent | 04d8afe7a3b36b57f6497c60dc6184e9dfeb85c1 (diff) |
Prevent brace initialization of AlphaNum
This was not intended to be supported, and it has resulted in calls as `absl::StrCat({...})`, which are not supported and only work coincidentally for the first 4 arguments due to `absl::StrCat` having overloads that take `absl::AlphaNum` directly for those.
The existing situation prevents modifying the implementations of such functions to alternatives that do not have such overloads for those arguments.
PiperOrigin-RevId: 599872755
Change-Id: I02c90119b2b96a922cf7e3b5d5f02affe24a272d
Diffstat (limited to 'absl')
-rw-r--r-- | absl/strings/str_cat.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h index ea2c4dca..bc8ea7d4 100644 --- a/absl/strings/str_cat.h +++ b/absl/strings/str_cat.h @@ -93,6 +93,7 @@ #include <cstddef> #include <cstdint> #include <cstring> +#include <initializer_list> #include <string> #include <type_traits> #include <utility> @@ -312,6 +313,10 @@ class AlphaNum { // No bool ctor -- bools convert to an integral type. // A bool ctor would also convert incoming pointers (bletch). + // Prevent brace initialization + template <typename T> + AlphaNum(std::initializer_list<T>) = delete; // NOLINT(runtime/explicit) + AlphaNum(int x) // NOLINT(runtime/explicit) : piece_(digits_, static_cast<size_t>( numbers_internal::FastIntToBuffer(x, digits_) - |