Skip to content

Commit

Permalink
Replace FOLLY_INLINE_VARIABLE with inline
Browse files Browse the repository at this point in the history
Summary: We moved to C++17. FOLLY_INLINE_VARIABLE is unnecessary.

Reviewed By: thedavekwon

Differential Revision: D51440983

fbshipit-source-id: 490b9ff0d3deea069dfadaacd4eeb3e65ae8782a
  • Loading branch information
TJ Yin authored and facebook-github-bot committed Nov 19, 2023
1 parent 637460d commit 0d87d20
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 131 deletions.
4 changes: 2 additions & 2 deletions thrift/lib/cpp/util/EnumUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace util {

/// Return whether EnumType is a thrift defined enum type
template <typename EnumType, typename = void>
FOLLY_INLINE_VARIABLE constexpr bool is_thrift_enum_v = false;
inline constexpr bool is_thrift_enum_v = false;

template <typename EnumType>
FOLLY_INLINE_VARIABLE constexpr bool is_thrift_enum_v<
inline constexpr bool is_thrift_enum_v<
EnumType,
folly::void_t<decltype(TEnumTraits<EnumType>::size)>> = true;

Expand Down
15 changes: 7 additions & 8 deletions thrift/lib/cpp2/FieldRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -817,17 +817,16 @@ bool operator!=(std::nullopt_t, const optional_field_ref<T>& a) {
namespace detail {

template <typename T>
FOLLY_INLINE_VARIABLE constexpr bool is_boxed_value_ptr_v = false;
inline constexpr bool is_boxed_value_ptr_v = false;

template <typename T>
FOLLY_INLINE_VARIABLE constexpr bool is_boxed_value_ptr_v<boxed_value_ptr<T>> =
true;
inline constexpr bool is_boxed_value_ptr_v<boxed_value_ptr<T>> = true;

template <typename T>
FOLLY_INLINE_VARIABLE constexpr bool is_boxed_value_v = false;
inline constexpr bool is_boxed_value_v = false;

template <typename T>
FOLLY_INLINE_VARIABLE constexpr bool is_boxed_value_v<boxed_value<T>> = true;
inline constexpr bool is_boxed_value_v<boxed_value<T>> = true;

template <typename From, typename To>
using copy_reference_t = std::conditional_t<
Expand Down Expand Up @@ -1945,14 +1944,14 @@ struct union_field_ref_owner_vtable_impl {
};

template <typename T>
FOLLY_INLINE_VARIABLE constexpr union_field_ref_owner_vtable //
inline constexpr union_field_ref_owner_vtable //
union_field_ref_owner_vtable_for{nullptr};
template <typename T>
FOLLY_INLINE_VARIABLE constexpr union_field_ref_owner_vtable //
inline constexpr union_field_ref_owner_vtable //
union_field_ref_owner_vtable_for<T&>{
&union_field_ref_owner_vtable_impl::reset<T>};
template <typename T>
FOLLY_INLINE_VARIABLE constexpr union_field_ref_owner_vtable //
inline constexpr union_field_ref_owner_vtable //
union_field_ref_owner_vtable_for<const T&>{nullptr};

} // namespace detail
Expand Down
49 changes: 22 additions & 27 deletions thrift/lib/cpp2/FieldRefTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,55 +40,50 @@ class terse_field_ref;

namespace detail {
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_field_ref_v = false;
inline constexpr bool is_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_field_ref_v<field_ref<T>> = true;
inline constexpr bool is_field_ref_v<field_ref<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_optional_field_ref_v = false;
inline constexpr bool is_optional_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool
is_optional_field_ref_v<optional_field_ref<T>> = true;
inline constexpr bool is_optional_field_ref_v<optional_field_ref<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_required_field_ref_v = false;
inline constexpr bool is_required_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool
is_required_field_ref_v<required_field_ref<T>> = true;
inline constexpr bool is_required_field_ref_v<required_field_ref<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_optional_boxed_field_ref_v = false;
inline constexpr bool is_optional_boxed_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool
inline constexpr bool
is_optional_boxed_field_ref_v<optional_boxed_field_ref<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_union_field_ref_v = false;
inline constexpr bool is_union_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_union_field_ref_v<union_field_ref<T>> =
true;
inline constexpr bool is_union_field_ref_v<union_field_ref<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_intern_boxed_field_ref_v = false;
inline constexpr bool is_intern_boxed_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool
is_intern_boxed_field_ref_v<intern_boxed_field_ref<T>> = true;
inline constexpr bool is_intern_boxed_field_ref_v<intern_boxed_field_ref<T>> =
true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_terse_intern_boxed_field_ref_v = false;
inline constexpr bool is_terse_intern_boxed_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool
inline constexpr bool
is_terse_intern_boxed_field_ref_v<terse_intern_boxed_field_ref<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_terse_field_ref_v = false;
inline constexpr bool is_terse_field_ref_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_terse_field_ref_v<terse_field_ref<T>> =
true;
inline constexpr bool is_terse_field_ref_v<terse_field_ref<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_unique_ptr_v = false;
inline constexpr bool is_unique_ptr_v = false;
template <class T, class D>
FOLLY_INLINE_VARIABLE constexpr bool is_unique_ptr_v<std::unique_ptr<T, D>> =
true;
inline constexpr bool is_unique_ptr_v<std::unique_ptr<T, D>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_shared_ptr_v = false;
inline constexpr bool is_shared_ptr_v = false;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_shared_ptr_v<std::shared_ptr<T>> = true;
inline constexpr bool is_shared_ptr_v<std::shared_ptr<T>> = true;
template <class T>
FOLLY_INLINE_VARIABLE constexpr bool is_shared_or_unique_ptr_v =
inline constexpr bool is_shared_or_unique_ptr_v =
is_unique_ptr_v<T> || is_shared_ptr_v<T>;

} // namespace detail
Expand Down
11 changes: 5 additions & 6 deletions thrift/lib/cpp2/Thrift.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct invoke_reffer;
template <typename Tag>
using access_field_fn = detail::invoke_reffer<Tag>;
template <typename Tag>
FOLLY_INLINE_VARIABLE constexpr access_field_fn<Tag> access_field{};
inline constexpr access_field_fn<Tag> access_field{};

enum FragileConstructor {
FRAGILE,
Expand Down Expand Up @@ -181,17 +181,16 @@ struct IsThriftUnion<T, folly::void_t<typename T::__fbthrift_cpp2_type>>
// before deserialization so that it only clears out terse fields in a terse
// struct.
using clear_terse_fields_fn = private_access::clear_terse_fields_fn;
FOLLY_INLINE_VARIABLE static constexpr clear_terse_fields_fn
clear_terse_fields{};
inline static constexpr clear_terse_fields_fn clear_terse_fields{};

} // namespace st
} // namespace detail

using clear_fn = detail::st::private_access::clear_fn;
FOLLY_INLINE_VARIABLE constexpr clear_fn clear{};
inline constexpr clear_fn clear{};

using empty_fn = detail::st::private_access::empty_fn;
FOLLY_INLINE_VARIABLE static constexpr empty_fn empty{};
inline static constexpr empty_fn empty{};

// TODO(dokwon): Add apache::thrift::uri support for generated enum types.
template <typename T>
Expand Down Expand Up @@ -321,7 +320,7 @@ struct apply_indirection_fn {
};
} // namespace detail

FOLLY_INLINE_VARIABLE constexpr detail::apply_indirection_fn apply_indirection;
inline constexpr detail::apply_indirection_fn apply_indirection;

class ExceptionMetadataOverrideBase {
public:
Expand Down
2 changes: 1 addition & 1 deletion thrift/lib/cpp2/gen/module_types_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ FOLLY_ERASE bool enum_find_value(
template <typename TypeClass>
struct copy_field_fn;
template <typename TypeClass>
FOLLY_INLINE_VARIABLE constexpr copy_field_fn<TypeClass> copy_field{};
inline constexpr copy_field_fn<TypeClass> copy_field{};

template <typename>
struct copy_field_rec {
Expand Down
4 changes: 2 additions & 2 deletions thrift/lib/cpp2/gen/module_types_h.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class FindOrdinal<T, folly::tag_t<Args...>> {
};

template <class T, class List>
FOLLY_INLINE_VARIABLE constexpr type::Ordinal FindOrdinalInUniqueTypes =
inline constexpr type::Ordinal FindOrdinalInUniqueTypes =
FindOrdinal<T, List>::value;

#if defined(__clang__) && \
Expand Down Expand Up @@ -399,7 +399,7 @@ struct FindOrdinalInUniqueTypesImpl<T, FBTHRIFT_PARAMS, Args...>
#undef FBTHRIFT_LOOKUP_SIZE

template <class T, class... Args>
FOLLY_INLINE_VARIABLE constexpr type::Ordinal
inline constexpr type::Ordinal
FindOrdinalInUniqueTypes<T, folly::tag_t<Args...>> =
FindOrdinalInUniqueTypesImpl<T, Args...>::value;
#endif
Expand Down
12 changes: 5 additions & 7 deletions thrift/lib/cpp2/op/Clear.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace op {
/// * isEmpty<set<i32_t>>({}) -> true
/// * isEmpty<set<i32_t>>({0}) -> false
template <typename Tag = void>
FOLLY_INLINE_VARIABLE constexpr detail::IsEmpty<Tag> isEmpty{};
inline constexpr detail::IsEmpty<Tag> isEmpty{};

/// Returns the default for the given type.
///
Expand All @@ -50,8 +50,7 @@ FOLLY_INLINE_VARIABLE constexpr detail::IsEmpty<Tag> isEmpty{};
/// * getDefault<type::string_t>() -> ""
/// * getDefault<int32_t>() -> 0
template <typename TagOrT>
FOLLY_INLINE_VARIABLE constexpr detail::GetDefault<type::infer_tag<TagOrT>>
getDefault{};
inline constexpr detail::GetDefault<type::infer_tag<TagOrT>> getDefault{};

/// Returns the 'intrinsic' default for the given type.
///
Expand All @@ -62,8 +61,7 @@ FOLLY_INLINE_VARIABLE constexpr detail::GetDefault<type::infer_tag<TagOrT>>
/// * getIntrinsicDefault<type::string_t>() -> ""
/// * getIntrinsicDefault<int32_t>() -> 0
template <typename TagOrT>
FOLLY_INLINE_VARIABLE constexpr detail::GetIntrinsicDefault<
type::infer_tag<TagOrT>>
inline constexpr detail::GetIntrinsicDefault<type::infer_tag<TagOrT>>
getIntrinsicDefault{};

/// Clears the given value, leaving it equal to its intrinsic default.
Expand All @@ -73,7 +71,7 @@ FOLLY_INLINE_VARIABLE constexpr detail::GetIntrinsicDefault<
/// * clear<set<i32_t>>(myIntSet) // calls myIntSet.clear()
/// * clear<ident::foo>(myStruct) // calls myStruct.foo().reset()
template <typename TagOrId = void, typename PTag = void>
FOLLY_INLINE_VARIABLE constexpr detail::Clear<TagOrId, PTag> clear{};
inline constexpr detail::Clear<TagOrId, PTag> clear{};

/// Clears the given field, setting the field to initial state.
///
Expand All @@ -85,7 +83,7 @@ FOLLY_INLINE_VARIABLE constexpr detail::Clear<TagOrId, PTag> clear{};
///
// TODO(afuller): Migrate all usage to op::clear<Id>(struct) and remove.
template <typename Tag>
FOLLY_INLINE_VARIABLE constexpr detail::ClearField<Tag> clear_field{};
inline constexpr detail::ClearField<Tag> clear_field{};

} // namespace op
} // namespace thrift
Expand Down
13 changes: 4 additions & 9 deletions thrift/lib/cpp2/op/Compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ struct EqualTo : detail::EqualTo<LTag, RTag> {};
/// * equal<float_t>(NaN, NaN) -> false
/// * equal<list<double_t>>([NaN, 0.0], [NaN, -0.0]) -> false
template <typename LTagOrT = void, typename RTagOrT = LTagOrT>
FOLLY_INLINE_VARIABLE constexpr EqualTo<
type::infer_tag<LTagOrT>,
type::infer_tag<RTagOrT>>
inline constexpr EqualTo<type::infer_tag<LTagOrT>, type::infer_tag<RTagOrT>>
equal{};

template <typename Tag = void>
Expand All @@ -53,8 +51,7 @@ struct IdenticalTo : detail::IdenticalTo<Tag> {};
/// * identical<float_t>(NaN, NaN) -> true
/// * identical<list<double_t>>([NaN, 0.0], [NaN, -0.0]) -> false
template <typename TagOrT = void>
FOLLY_INLINE_VARIABLE constexpr IdenticalTo<type::infer_tag<TagOrT>>
identical{};
inline constexpr IdenticalTo<type::infer_tag<TagOrT>> identical{};

template <typename LTag = void, typename RTag = LTag>
struct Less : detail::LessThan<LTag, RTag> {};
Expand All @@ -67,9 +64,7 @@ struct Less : detail::LessThan<LTag, RTag> {};
/// * less<double_t>(0.0, -0.0) -> false
/// * less<float_t>(NaN, NaN) -> false
template <typename LTagOrT = void, typename RTagOrT = LTagOrT>
FOLLY_INLINE_VARIABLE constexpr Less<
type::infer_tag<LTagOrT>,
type::infer_tag<RTagOrT>>
inline constexpr Less<type::infer_tag<LTagOrT>, type::infer_tag<RTagOrT>>
less{};

/// Compares two Thrift values, returning the associated folly::ordering value.
Expand All @@ -79,7 +74,7 @@ FOLLY_INLINE_VARIABLE constexpr Less<
/// * less<double_t>(0.0, -0.0) -> folly::ordering::eq
/// * compare<string_t>("aa", "a") -> folly::ordering::gt
template <typename LTagOrT = void, typename RTagOrT = LTagOrT>
FOLLY_INLINE_VARIABLE constexpr detail::
inline constexpr detail::
CompareWith<type::infer_tag<LTagOrT>, type::infer_tag<RTagOrT>>
compare{};

Expand Down
2 changes: 1 addition & 1 deletion thrift/lib/cpp2/op/Copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace op {
/// * copy(src.shared_ptr_ref(), dst.shared_ptr_ref())
/// // If src is nullptr, it sets dst to nullptr, otherwise shares the
/// pointer.
FOLLY_INLINE_VARIABLE constexpr detail::Copy copy{};
inline constexpr detail::Copy copy{};

} // namespace op
} // namespace thrift
Expand Down
4 changes: 2 additions & 2 deletions thrift/lib/cpp2/op/Create.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ namespace op {
/// * create<field_t<FieldId, adapted<FieldAdapter, type::i32_t>>>(Struct)
/// -> AdaptedWithContext<int32_t>{};
template <typename Tag>
FOLLY_INLINE_VARIABLE constexpr detail::Create<Tag> create{};
inline constexpr detail::Create<Tag> create{};

/// Ensures the given field. If the field doesn't exist, emplaces the field.
/// For example:
/// * ensure<field_tag>(foo)
/// // calls foo.field_ref().ensure()
template <typename Id = void, typename Tag = void>
FOLLY_INLINE_VARIABLE constexpr detail::Ensure<Id, Tag> ensure{};
inline constexpr detail::Ensure<Id, Tag> ensure{};

} // namespace op
} // namespace thrift
Expand Down
7 changes: 3 additions & 4 deletions thrift/lib/cpp2/op/Encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@ namespace op {
/// Returns the serialized size of the avlue using the type tag.
/// For example: serialized_size<false, type::int16_t>(prot, 1);
template <bool ZeroCopy, typename Tag>
FOLLY_INLINE_VARIABLE constexpr detail::SerializedSize<ZeroCopy, Tag>
serialized_size{};
inline constexpr detail::SerializedSize<ZeroCopy, Tag> serialized_size{};

/// Encodes the given value to the given protocol using the type tag.
/// This handles adapted type.
/// For example: encode<type::int16_t>(prot, 1);
template <typename Tag>
FOLLY_INLINE_VARIABLE constexpr detail::Encode<Tag> encode{};
inline constexpr detail::Encode<Tag> encode{};

/// Decodes the value from the given protocol using the type tag.
/// This handles adapted type.
/// For example: decode<type::int16_t>(prot, i); // decode to variable i
template <typename Tag>
FOLLY_INLINE_VARIABLE constexpr detail::Decode<Tag> decode{};
inline constexpr detail::Decode<Tag> decode{};

} // namespace op
} // namespace thrift
Expand Down
Loading

0 comments on commit 0d87d20

Please sign in to comment.