From 20089ec0e4cd409cb5428223db168f5e88d7035f Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Mon, 26 Jun 2023 10:31:09 -0700 Subject: AnyInvocable: Use enums instead of ints in initialization overload set This trick was introduced to work around a compiler bug in msvc 2017, which abseil doesn't support anymore: https://github.com/google/oss-policies-info/blob/3aa4b98f497fdfac983b8de78cf6bd693cb0cf4f/foundational-cxx-support-matrix.md PiperOrigin-RevId: 543477428 Change-Id: I332c1b359b75811536ce900d3166979ac3c196a3 --- absl/functional/internal/any_invocable.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/absl/functional/internal/any_invocable.h b/absl/functional/internal/any_invocable.h index a52fa876..f096bb02 100644 --- a/absl/functional/internal/any_invocable.h +++ b/absl/functional/internal/any_invocable.h @@ -440,11 +440,11 @@ class CoreImpl { CoreImpl() noexcept : manager_(EmptyManager), invoker_(nullptr) {} - enum class TargetType : int { - kPointer = 0, - kCompatibleAnyInvocable = 1, - kIncompatibleAnyInvocable = 2, - kOther = 3, + enum class TargetType { + kPointer, + kCompatibleAnyInvocable, + kIncompatibleAnyInvocable, + kOther, }; // Note: QualDecayedTRef here includes the cv-ref qualifiers associated with @@ -466,8 +466,7 @@ class CoreImpl { // NOTE: We only use integers instead of enums as template parameters in // order to work around a bug on C++14 under MSVC 2017. // See b/236131881. - Initialize(kTargetType), QualDecayedTRef>( - std::forward(f)); + Initialize(std::forward(f)); } // Note: QualTRef here includes the cv-ref qualifiers associated with the @@ -518,8 +517,8 @@ class CoreImpl { invoker_ = nullptr; } - template = 0> + template = 0> void Initialize(F&& f) { // This condition handles types that decay into pointers, which includes // function references. Since function references cannot be null, GCC warns @@ -543,8 +542,9 @@ class CoreImpl { InitializeStorage(std::forward(f)); } - template = 0> + template = 0> void Initialize(F&& f) { // In this case we can "steal the guts" of the other AnyInvocable. f.manager_(FunctionToCall::relocate_from_to, &f.state_, &state_); @@ -555,8 +555,9 @@ class CoreImpl { f.invoker_ = nullptr; } - template = 0> + template = 0> void Initialize(F&& f) { if (f.HasValue()) { InitializeStorage(std::forward(f)); @@ -566,8 +567,8 @@ class CoreImpl { } } - template > + template > void Initialize(F&& f) { InitializeStorage(std::forward(f)); } -- cgit v1.2.3