Commit 2be67701 by Abseil Team Committed by Copybara-Service

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
parent 04d8afe7
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <initializer_list>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
...@@ -312,6 +313,10 @@ class AlphaNum { ...@@ -312,6 +313,10 @@ class AlphaNum {
// No bool ctor -- bools convert to an integral type. // No bool ctor -- bools convert to an integral type.
// A bool ctor would also convert incoming pointers (bletch). // 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) AlphaNum(int x) // NOLINT(runtime/explicit)
: piece_(digits_, static_cast<size_t>( : piece_(digits_, static_cast<size_t>(
numbers_internal::FastIntToBuffer(x, digits_) - numbers_internal::FastIntToBuffer(x, digits_) -
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment