diff --git a/third-party/thrift/src/thrift/lib/cpp2/op/AssignPatch.h b/third-party/thrift/src/thrift/lib/cpp2/op/AssignPatch.h index 97ead6be14bf58..2454763e9c8f85 100644 --- a/third-party/thrift/src/thrift/lib/cpp2/op/AssignPatch.h +++ b/third-party/thrift/src/thrift/lib/cpp2/op/AssignPatch.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include namespace apache::thrift { @@ -138,6 +138,17 @@ class AssignPatch : public BaseAssignPatch> { Base::reset(); } + template > + static auto fromSafePatch( + const typename std::enable_if_t>::type& + safePatch) { + return fromSafePatchImpl(safePatch); + } + + auto toSafePatch() const { + return toSafePatchImpl::type>(*this); + } + private: using Base::data_; std::optional dynPatch_; diff --git a/third-party/thrift/src/thrift/lib/cpp2/op/detail/PatchTraits.h b/third-party/thrift/src/thrift/lib/cpp2/op/detail/PatchTraits.h index 062a903dd6c6f4..39624eff6d9b3f 100644 --- a/third-party/thrift/src/thrift/lib/cpp2/op/detail/PatchTraits.h +++ b/third-party/thrift/src/thrift/lib/cpp2/op/detail/PatchTraits.h @@ -107,6 +107,10 @@ template constexpr inline bool is_any_patch_v = false; template constexpr inline bool is_any_patch_v> = true; +template +constexpr inline bool is_assign_patch_v = false; +template +constexpr inline bool is_assign_patch_v> = true; class MinSafePatchVersionVisitor { public: @@ -170,9 +174,13 @@ class MinSafePatchVersionVisitor { template int32_t calculateMinSafePatchVersion(const Patch& patch) { // is_patch_v - MinSafePatchVersionVisitor visitor; - patch.customVisit(visitor); - return visitor.version; + if constexpr (is_assign_patch_v) { + return 1; + } else { + MinSafePatchVersionVisitor visitor; + patch.customVisit(visitor); + return visitor.version; + } } } // namespace apache::thrift::op::detail