Skip to content

Commit

Permalink
Refactor is_patch_v to PatchTraits
Browse files Browse the repository at this point in the history
Summary: Need public `PatchTraits` to re-use `is_patch_v` to avoid cyclic dependency.

Reviewed By: praihan

Differential Revision: D68005445

fbshipit-source-id: 0d3c72caeb1a394f6c0676d0f9c2df0232997fa7
  • Loading branch information
thedavekwon authored and facebook-github-bot committed Jan 13, 2025
1 parent a010f76 commit 7d4f4c4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
11 changes: 1 addition & 10 deletions third-party/thrift/src/thrift/lib/cpp2/op/Patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

#pragma once

#include <type_traits>

#include <fmt/core.h>
#include <thrift/lib/cpp2/Thrift.h>
#include <thrift/lib/cpp2/op/Encode.h>
#include <thrift/lib/cpp2/op/PatchTraits.h>
#include <thrift/lib/cpp2/op/detail/Patch.h>
#include <thrift/lib/cpp2/protocol/DebugProtocol.h>
#include <thrift/lib/cpp2/type/Tag.h>
Expand Down Expand Up @@ -114,14 +113,6 @@ using safe_patch_value_type = typename detail::SafePatchValueType<T>::type;
template <typename T>
using patch_type = typename detail::PatchType<type::infer_tag<T>>::type;

template <typename T, typename = void>
inline constexpr bool is_patch_v = false;

template <typename T>
inline constexpr bool
is_patch_v<T, folly::void_t<typename T::underlying_type>> =
std::is_base_of_v<detail::BasePatch<typename T::underlying_type, T>, T>;

template <typename T>
inline constexpr bool is_assign_only_patch_v = false;
template <typename T>
Expand Down
34 changes: 34 additions & 0 deletions third-party/thrift/src/thrift/lib/cpp2/op/PatchTraits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <type_traits>

#include <thrift/lib/cpp2/op/detail/BasePatch.h>
#include <thrift/lib/cpp2/op/detail/PatchTraits.h>

namespace apache::thrift::op {

template <typename T, typename = void>
inline constexpr bool is_patch_v = false;

template <typename T>
inline constexpr bool
is_patch_v<T, folly::void_t<typename T::underlying_type>> =
std::is_base_of_v<detail::BasePatch<typename T::underlying_type, T>, T>;

} // namespace apache::thrift::op

0 comments on commit 7d4f4c4

Please sign in to comment.