diff --git a/thrift/compiler/lib/schematizer.cc b/thrift/compiler/lib/schematizer.cc index 5d961362692..4f56c99ad35 100644 --- a/thrift/compiler/lib/schematizer.cc +++ b/thrift/compiler/lib/schematizer.cc @@ -37,7 +37,7 @@ template std::unique_ptr val(Args&&... args) { return std::make_unique(std::forward(args)...); } -template ::value>> +template >> std::unique_ptr val(Enm val) { return std::make_unique( static_cast>(val)); diff --git a/thrift/compiler/sema/sema_context.h b/thrift/compiler/sema/sema_context.h index 9d3eff855d2..dd22499e631 100644 --- a/thrift/compiler/sema/sema_context.h +++ b/thrift/compiler/sema/sema_context.h @@ -36,7 +36,7 @@ class node_metadata_cache { using element_type = typename decltype(std::declval()())::element_type; template using if_is_constructible = - std::enable_if_t::value, T&>; + std::enable_if_t, T&>; using key_type = std::pair; public: diff --git a/thrift/compiler/test/const_util_test.cc b/thrift/compiler/test/const_util_test.cc index 9e5a38968a6..29728a927da 100644 --- a/thrift/compiler/test/const_util_test.cc +++ b/thrift/compiler/test/const_util_test.cc @@ -26,7 +26,7 @@ template std::unique_ptr val(Args&&... args) { return std::make_unique(std::forward(args)...); } -template ::value>> +template >> std::unique_ptr val(Enum val) { return std::make_unique( static_cast>(val)); diff --git a/thrift/lib/cpp2/Adapt.h b/thrift/lib/cpp2/Adapt.h index a0859e60923..1242647d00b 100644 --- a/thrift/lib/cpp2/Adapt.h +++ b/thrift/lib/cpp2/Adapt.h @@ -499,8 +499,8 @@ struct adapter_serialized_size< Adapter, AdaptedT, Protocol> && - std::is_arithmetic()))>::value>> { + std::is_arithmetic_v()))>>> { uint32_t operator()(Protocol& prot, const AdaptedT&, FallbackF) { return serializedSizeFixed( prot, decltype(Adapter::toThrift(std::declval()))(0)); diff --git a/thrift/lib/cpp2/FieldRef.h b/thrift/lib/cpp2/FieldRef.h index f1be301de86..ac273be23ba 100644 --- a/thrift/lib/cpp2/FieldRef.h +++ b/thrift/lib/cpp2/FieldRef.h @@ -37,8 +37,7 @@ namespace apache::thrift { namespace detail { template -using is_set_t = - std::conditional_t::value, const uint8_t, uint8_t>; +using is_set_t = std::conditional_t, const uint8_t, uint8_t>; [[noreturn]] void throw_on_bad_optional_field_access(); [[noreturn]] void throw_on_bad_union_field_access(); @@ -237,11 +236,11 @@ class BitRef { template using EnableIfConst = - std::enable_if_t::value, return_type>; + std::enable_if_t, return_type>; template using EnableIfNonConst = - std::enable_if_t::value, return_type>; + std::enable_if_t, return_type>; template using EnableIfImplicit = std::enable_if_t< @@ -256,7 +255,7 @@ using EnableIfImplicit = std::enable_if_t< /// std::remove_reference_t in a Thrift-generated struct. template class field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); template friend class field_ref; @@ -269,8 +268,7 @@ class field_ref { using reference_type = T; private: - using BitRef = - apache::thrift::detail::BitRef::value>; + using BitRef = apache::thrift::detail::BitRef>; public: /// Internal constructor @@ -295,9 +293,9 @@ class field_ref { template FOLLY_ERASE - std::enable_if_t::value, field_ref&> + std::enable_if_t, field_ref&> operator=(U&& value) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { value_ = static_cast(value); bitref_ = true; return *this; @@ -305,7 +303,7 @@ class field_ref { // Workaround for https://bugs.llvm.org/show_bug.cgi?id=49442 FOLLY_ERASE field_ref& operator=(value_type&& value) noexcept( - std::is_nothrow_move_assignable::value) { + std::is_nothrow_move_assignable_v) { value_ = static_cast(value); bitref_ = true; return *this; @@ -316,7 +314,7 @@ class field_ref { /// rebinding. The copy_from method is provided instead. template FOLLY_ERASE void copy_from(field_ref other) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { value_ = other.value(); bitref_ = other.is_set(); } @@ -393,8 +391,7 @@ class field_ref { /// Constructs the value in-place. template FOLLY_ERASE std::enable_if_t< - std::is_constructible, Args&&...>:: - value, + std::is_constructible_v, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { bitref_ = false; @@ -502,7 +499,7 @@ bool operator>=(const T& lhs, field_ref rhs) { // std::remove_reference_t in a Thrift-generated struct. template class optional_field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); template friend class optional_field_ref; @@ -515,8 +512,7 @@ class optional_field_ref { using reference_type = T; private: - using BitRef = - apache::thrift::detail::BitRef::value>; + using BitRef = apache::thrift::detail::BitRef>; // for alias_isset_fn FOLLY_ERASE optional_field_ref(reference_type value, BitRef bitref) @@ -552,11 +548,10 @@ class optional_field_ref { : value_(other.value_), bitref_(other.bitref_) {} template - FOLLY_ERASE std::enable_if_t< - std::is_assignable::value, - optional_field_ref&> - operator=(U&& value) noexcept( - std::is_nothrow_assignable::value) { + FOLLY_ERASE std:: + enable_if_t, optional_field_ref&> + operator=(U&& value) noexcept( + std::is_nothrow_assignable_v) { value_ = static_cast(value); bitref_ = true; return *this; @@ -564,7 +559,7 @@ class optional_field_ref { // Workaround for https://bugs.llvm.org/show_bug.cgi?id=49442 FOLLY_ERASE optional_field_ref& operator=(value_type&& value) noexcept( - std::is_nothrow_move_assignable::value) { + std::is_nothrow_move_assignable_v) { value_ = static_cast(value); bitref_ = true; return *this; @@ -578,22 +573,21 @@ class optional_field_ref { // rebinding. This copy_from method is provided instead. template FOLLY_ERASE void copy_from(const optional_field_ref& other) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { value_ = other.value_unchecked(); bitref_ = other.has_value(); } template FOLLY_ERASE void move_from(optional_field_ref other) noexcept( - std::is_nothrow_assignable&&>:: - value) { + std::is_nothrow_assignable_v&&>) { value_ = static_cast&&>(other.value_); bitref_ = other.has_value(); } template FOLLY_ERASE void from_optional(const std::optional& other) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { // Use if instead of a shorter ternary expression to prevent a potential // copy if T and U mismatch. if (other) { @@ -608,7 +602,7 @@ class optional_field_ref { // move_from doesn't make other empty. template FOLLY_ERASE void from_optional(std::optional&& other) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { // Use if instead of a shorter ternary expression to prevent a potential // copy if T and U mismatch. if (other) { @@ -630,7 +624,7 @@ class optional_field_ref { FOLLY_ERASE explicit operator bool() const noexcept { return bool(bitref_); } FOLLY_ERASE void reset() noexcept( - std::is_nothrow_move_assignable::value) { + std::is_nothrow_move_assignable_v) { value_ = value_type(); bitref_ = false; } @@ -679,7 +673,7 @@ class optional_field_ref { } FOLLY_ERASE reference_type - ensure() noexcept(std::is_nothrow_move_assignable::value) { + ensure() noexcept(std::is_nothrow_move_assignable_v) { if (!bitref_) { value_ = value_type(); bitref_ = true; @@ -698,8 +692,7 @@ class optional_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_constructible&, Args&&...>:: - value, + std::is_constructible_v&, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { reset(); @@ -859,7 +852,7 @@ using copy_const_t = std::conditional_t< template class optional_boxed_field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); static_assert( detail::is_boxed_value_ptr_v>, "not a boxed_value_ptr"); @@ -896,7 +889,7 @@ class optional_boxed_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_assignable::value, + std::is_assignable_v, optional_boxed_field_ref&> operator=(U&& value) { value_ = static_cast(value); @@ -1012,8 +1005,7 @@ class optional_boxed_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_constructible&, Args&&...>:: - value, + std::is_constructible_v&, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { reset(); @@ -1158,7 +1150,7 @@ bool operator!=(std::nullopt_t, const optional_boxed_field_ref& a) { // It currently only supports Thrift structs. template class intern_boxed_field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); static_assert( detail::is_boxed_value_v>, "not a boxed_value"); @@ -1179,8 +1171,7 @@ class intern_boxed_field_ref { using reference_type = detail::copy_reference_t; private: - using BitRef = - apache::thrift::detail::BitRef::value>; + using BitRef = apache::thrift::detail::BitRef>; public: FOLLY_ERASE intern_boxed_field_ref( @@ -1206,7 +1197,7 @@ class intern_boxed_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_assignable::value, + std::is_assignable_v, intern_boxed_field_ref&> operator=(U&& value) { value_.mut() = static_cast(value); @@ -1216,7 +1207,7 @@ class intern_boxed_field_ref { // Workaround for https://bugs.llvm.org/show_bug.cgi?id=49442 FOLLY_ERASE intern_boxed_field_ref& operator=(value_type&& value) noexcept( - std::is_nothrow_move_assignable::value) { + std::is_nothrow_move_assignable_v) { value_.mut() = static_cast(value); bitref_ = true; return *this; @@ -1296,8 +1287,7 @@ class intern_boxed_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_constructible&, Args&&...>:: - value, + std::is_constructible_v&, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { bitref_ = false; @@ -1408,7 +1398,7 @@ bool operator>=(const U& a, intern_boxed_field_ref b) { // It currently only supports Thrift structs. template class terse_intern_boxed_field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); static_assert( detail::is_boxed_value_v>, "not a boxed_value"); @@ -1439,7 +1429,7 @@ class terse_intern_boxed_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_assignable::value, + std::is_assignable_v, terse_intern_boxed_field_ref&> operator=(U&& value) { value_.mut() = static_cast(value); @@ -1449,7 +1439,7 @@ class terse_intern_boxed_field_ref { // Workaround for https://bugs.llvm.org/show_bug.cgi?id=49442 FOLLY_ERASE terse_intern_boxed_field_ref& operator=(value_type&& value) noexcept( - std::is_nothrow_move_assignable::value) { + std::is_nothrow_move_assignable_v) { value_.mut() = static_cast(value); return *this; } @@ -1461,8 +1451,7 @@ class terse_intern_boxed_field_ref { template FOLLY_ERASE void move_from(terse_intern_boxed_field_ref other) noexcept( - std::is_nothrow_assignable&&>:: - value) { + std::is_nothrow_assignable_v&&>) { value_ = static_cast&&>(other.value_); } @@ -1511,8 +1500,7 @@ class terse_intern_boxed_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_constructible&, Args&&...>:: - value, + std::is_constructible_v&, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { value_.reset( @@ -1804,7 +1792,7 @@ constexpr apache::thrift::detail::alias_isset_fn alias_isset; // std::remove_reference_t in a Thrift-generated struct. template class required_field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); template friend class required_field_ref; @@ -1824,18 +1812,17 @@ class required_field_ref { : value_(other.value_) {} template - FOLLY_ERASE std::enable_if_t< - std::is_assignable::value, - required_field_ref&> - operator=(U&& value) noexcept( - std::is_nothrow_assignable::value) { + FOLLY_ERASE std:: + enable_if_t, required_field_ref&> + operator=(U&& value) noexcept( + std::is_nothrow_assignable_v) { value_ = static_cast(value); return *this; } // Workaround for https://bugs.llvm.org/show_bug.cgi?id=49442 FOLLY_ERASE required_field_ref& operator=(value_type&& value) noexcept( - std::is_nothrow_move_assignable::value) { + std::is_nothrow_move_assignable_v) { value_ = static_cast(value); return *this; } @@ -1845,7 +1832,7 @@ class required_field_ref { // rebinding. The copy_from method is provided instead. template FOLLY_ERASE void copy_from(required_field_ref other) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { value_ = other.value(); } @@ -1896,8 +1883,7 @@ class required_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_constructible, Args&&...>:: - value, + std::is_constructible_v, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { return value_ = value_type(ilist, static_cast(args)...); @@ -2028,7 +2014,7 @@ inline constexpr union_field_ref_owner_vtable // // A reference to an union field of the possibly const-qualified type template class union_field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); template friend class union_field_ref; @@ -2075,12 +2061,12 @@ class union_field_ref { template < typename U = value_type, std::enable_if_t< - std::is_assignable::value && - std::is_constructible::value, + std::is_assignable_v && + std::is_constructible_v, int> = 0> FOLLY_ERASE union_field_ref& operator=(U&& other) noexcept( - std::is_nothrow_constructible::value && - std::is_nothrow_assignable::value) { + std::is_nothrow_constructible_v && + std::is_nothrow_assignable_v) { if (has_value() && !detail::is_shared_or_unique_ptr_v>) { get_value() = static_cast(other); @@ -2149,8 +2135,7 @@ class union_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_constructible, Args&&...>:: - value, + std::is_constructible_v, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { vtable_.reset(owner_); @@ -2309,7 +2294,7 @@ struct union_value_unsafe_fn { // or unset. template class terse_field_ref { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); template friend class terse_field_ref; @@ -2337,31 +2322,30 @@ class terse_field_ref { : value_(other.value_) {} template - FOLLY_ERASE std:: - enable_if_t::value, terse_field_ref&> + FOLLY_ERASE + std::enable_if_t, terse_field_ref&> operator=(U&& value) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { value_ = static_cast(value); return *this; } // Workaround for https://bugs.llvm.org/show_bug.cgi?id=49442 FOLLY_ERASE terse_field_ref& operator=(value_type&& value) noexcept( - std::is_nothrow_move_assignable::value) { + std::is_nothrow_move_assignable_v) { value_ = static_cast(value); return *this; } template FOLLY_ERASE void copy_from(const terse_field_ref& other) noexcept( - std::is_nothrow_assignable::value) { + std::is_nothrow_assignable_v) { value_ = other.value_; } template FOLLY_ERASE void move_from(terse_field_ref other) noexcept( - std::is_nothrow_assignable&&>:: - value) { + std::is_nothrow_assignable_v&&>) { value_ = static_cast&&>(other.value_); } @@ -2403,8 +2387,7 @@ class terse_field_ref { template FOLLY_ERASE std::enable_if_t< - std::is_constructible, Args&&...>:: - value, + std::is_constructible_v, Args&&...>, value_type&> emplace(std::initializer_list ilist, Args&&... args) { value_ = value_type(ilist, static_cast(args)...); diff --git a/thrift/lib/cpp2/GeneratedCodeHelper.h b/thrift/lib/cpp2/GeneratedCodeHelper.h index 3cdda6dc7db..c835deef8c7 100644 --- a/thrift/lib/cpp2/GeneratedCodeHelper.h +++ b/thrift/lib/cpp2/GeneratedCodeHelper.h @@ -127,7 +127,7 @@ struct FieldData { static const constexpr protocol::TType ttype = protocol_type_v; typedef TC type_class; typedef T type; - typedef typename std::remove_pointer::type value_type; + typedef std::remove_pointer_t value_type; using Ops = Cpp2Ops; T value; static_assert(std::is_pointer_v != std::is_base_of_v, ""); diff --git a/thrift/lib/cpp2/Thrift.h b/thrift/lib/cpp2/Thrift.h index 99843258318..619dda97596 100644 --- a/thrift/lib/cpp2/Thrift.h +++ b/thrift/lib/cpp2/Thrift.h @@ -206,8 +206,8 @@ constexpr bool is_thrift_union_v = apache::thrift::detail::st::IsThriftUnion::value; template -constexpr bool is_thrift_exception_v = is_thrift_class_v && - std::is_base_of::value; +constexpr bool is_thrift_exception_v = + is_thrift_class_v && std::is_base_of_v; template constexpr bool is_thrift_struct_v = @@ -226,7 +226,7 @@ using type_class_of_thrift_class_or_t = // template using type_class_of_thrift_class_enum_or_t = // folly::conditional_t< - std::is_enum::value, + std::is_enum_v, type_class::enumeration, type_class_of_thrift_class_or_t>; @@ -242,7 +242,7 @@ namespace detail { template struct enum_hash { size_t operator()(T t) const { - using underlying_t = typename std::underlying_type::type; + using underlying_t = std::underlying_type_t; return std::hash()(underlying_t(t)); } }; @@ -263,18 +263,14 @@ template struct is_safe_overload { using type = std::integral_constant< bool, - !std::is_same< - Class, - typename std::remove_cv< - typename std::remove_reference::type>::type>::value>; + !std::is_same_v>>>; }; } // namespace detail template -using safe_overload_t = typename std::enable_if< - apache::thrift::detail::is_safe_overload::type::value>:: - type; +using safe_overload_t = std::enable_if_t< + apache::thrift::detail::is_safe_overload::type::value>; } // namespace apache::thrift diff --git a/thrift/lib/cpp2/frozen/Frozen.h b/thrift/lib/cpp2/frozen/Frozen.h index a68e995a883..444a3471f7a 100644 --- a/thrift/lib/cpp2/frozen/Frozen.h +++ b/thrift/lib/cpp2/frozen/Frozen.h @@ -340,7 +340,7 @@ struct FieldBase { virtual void clear() = 0; }; -template ::type>> +template >> struct Field final : public FieldBase { Layout layout; @@ -975,7 +975,7 @@ class Bundled : public Base { Bundled& operator=(Bundled&&) = default; - template ::type> + template > Decayed* hold(T&& t) { std::unique_ptr> holder( new HolderImpl(std::forward(t))); @@ -989,7 +989,7 @@ class Bundled : public Base { holds_.push_back(std::move(holder)); } - template ::type> + template > const Decayed* findFirstOfType() const { for (const auto& h : holds_) { if (auto p = dynamic_cast*>(h.get())) { @@ -1063,7 +1063,7 @@ void thawField(ViewPosition self, const Field& f, field_ref ref) { template < class T, class D, - std::enable_if_t::value>> + std::enable_if_t>> void thawField( ViewPosition self, const Field>& f, diff --git a/thrift/lib/cpp2/frozen/HintTypes.h b/thrift/lib/cpp2/frozen/HintTypes.h index 3e2a06af81a..748e9ea1ba6 100644 --- a/thrift/lib/cpp2/frozen/HintTypes.h +++ b/thrift/lib/cpp2/frozen/HintTypes.h @@ -41,7 +41,7 @@ namespace apache::thrift::frozen { template class VectorUnpacked : public std::vector { static_assert( - std::is_arithmetic::value || std::is_enum::value, + std::is_arithmetic_v || std::is_enum_v, "Unpacked storage is only available for simple item types"); using std::vector::vector; }; diff --git a/thrift/lib/cpp2/gen/module_types_h.h b/thrift/lib/cpp2/gen/module_types_h.h index 0a129748360..ba136fca432 100644 --- a/thrift/lib/cpp2/gen/module_types_h.h +++ b/thrift/lib/cpp2/gen/module_types_h.h @@ -78,7 +78,7 @@ constexpr ptrdiff_t unionTypeOffset(); template struct wrapped_struct_argument { - static_assert(std::is_reference::value, "not a reference"); + static_assert(std::is_reference_v, "not a reference"); Ref ref; FOLLY_ERASE explicit wrapped_struct_argument(Ref ref_) : ref(static_cast(ref_)) {} @@ -115,8 +115,8 @@ wrap_struct_argument(T&& value) { } template -FOLLY_ERASE typename std::enable_if::value>::type -assign_struct_field(F f, T&& t, S&) { +FOLLY_ERASE std::enable_if_t> assign_struct_field( + F f, T&& t, S&) { f = static_cast(t); } template @@ -128,8 +128,8 @@ FOLLY_ERASE void assign_struct_field(std::shared_ptr& f, T&& t, S&) { f = std::make_shared>(static_cast(t)); } template -FOLLY_ERASE typename std::enable_if::value>::type -assign_struct_field(F f, T&& t, S& s) { +FOLLY_ERASE std::enable_if_t> assign_struct_field( + F f, T&& t, S& s) { f = ::apache::thrift::adapt_detail:: fromThriftField( static_cast(t), s); @@ -283,8 +283,7 @@ class FindOrdinal { template class FindOrdinal> { private: - static constexpr bool matches[sizeof...(Args)] = { - std::is_same::value...}; + static constexpr bool matches[sizeof...(Args)] = {std::is_same_v...}; public: static constexpr auto value = findOrdinal(matches, std::end(matches), true); @@ -408,7 +407,7 @@ inline constexpr type::Ordinal #endif template -FOLLY_CONSTEVAL std::enable_if_t::value, FieldOrdinal> +FOLLY_CONSTEVAL std::enable_if_t, FieldOrdinal> getFieldOrdinal(IdList&&) { return static_cast(0); } diff --git a/thrift/lib/cpp2/op/StdHasher.h b/thrift/lib/cpp2/op/StdHasher.h index ff476d2531b..241c87a68eb 100644 --- a/thrift/lib/cpp2/op/StdHasher.h +++ b/thrift/lib/cpp2/op/StdHasher.h @@ -30,12 +30,11 @@ class StdHasher { size_t getResult() const { return result_; } template - constexpr std::enable_if_t::value> combine( - const T& val) { + constexpr std::enable_if_t> combine(const T& val) { result_ = folly::hash::hash_combine(val, result_); } template - constexpr std::enable_if_t::value> combine(const T& val) { + constexpr std::enable_if_t> combine(const T& val) { combine(folly::to_underlying(val)); } void combine(folly::ByteRange value) { diff --git a/thrift/lib/cpp2/op/detail/BaseOp.h b/thrift/lib/cpp2/op/detail/BaseOp.h index 62a044b39ad..3b4d8279dd5 100644 --- a/thrift/lib/cpp2/op/detail/BaseOp.h +++ b/thrift/lib/cpp2/op/detail/BaseOp.h @@ -36,7 +36,7 @@ const TypeInfo& getAnyTypeInfo(); template > RuntimeType getAnyType() { static_assert( - std::is_same, type::native_type>::value, + std::is_same_v, type::native_type>, "type missmatch"); return RuntimeType::create(getAnyTypeInfo()); } diff --git a/thrift/lib/cpp2/op/detail/Encode.h b/thrift/lib/cpp2/op/detail/Encode.h index 823661b6786..52fb97190c5 100644 --- a/thrift/lib/cpp2/op/detail/Encode.h +++ b/thrift/lib/cpp2/op/detail/Encode.h @@ -42,7 +42,7 @@ namespace op::detail { template inline constexpr bool kIsStrongType = - std::is_enum>::value && + std::is_enum_v> && type::is_a_v; template diff --git a/thrift/lib/cpp2/protocol/JSONProtocolCommon-inl.h b/thrift/lib/cpp2/protocol/JSONProtocolCommon-inl.h index eac95d9a143..557ef5e3469 100644 --- a/thrift/lib/cpp2/protocol/JSONProtocolCommon-inl.h +++ b/thrift/lib/cpp2/protocol/JSONProtocolCommon-inl.h @@ -619,7 +619,7 @@ inline void JSONProtocolReaderCommon::readJSONVal(int64_t& val) { } template -inline typename std::enable_if::value>::type +inline typename std::enable_if_t> JSONProtocolReaderCommon::readJSONVal(Floating& val) { static_assert( std::numeric_limits::is_iec559, @@ -652,9 +652,8 @@ JSONProtocolReaderCommon::readJSONVal(Floating& val) { } template -inline - typename std::enable_if::value>::type - JSONProtocolReaderCommon::readJSONVal(Str& val) { +inline typename std::enable_if_t::value> +JSONProtocolReaderCommon::readJSONVal(Str& val) { readJSONString(val); } diff --git a/thrift/lib/cpp2/protocol/JSONProtocolCommon.h b/thrift/lib/cpp2/protocol/JSONProtocolCommon.h index 6c997ccd03b..c42391db45d 100644 --- a/thrift/lib/cpp2/protocol/JSONProtocolCommon.h +++ b/thrift/lib/cpp2/protocol/JSONProtocolCommon.h @@ -243,11 +243,11 @@ class JSONProtocolReaderCommon : public detail::ProtocolBase { void readJSONVal(int32_t& val); void readJSONVal(int64_t& val); template - typename std::enable_if::value>::type - readJSONVal(Floating& val); + std::enable_if_t> readJSONVal( + Floating& val); template - typename std::enable_if::value>::type - readJSONVal(Str& val); + std::enable_if_t::value> readJSONVal( + Str& val); bool JSONtoBool(const std::string& s); void readJSONVal(bool& val); void readJSONNull(); diff --git a/thrift/lib/cpp2/protocol/TableBasedSerializer.h b/thrift/lib/cpp2/protocol/TableBasedSerializer.h index f323d45fad5..12ba8dd8ac3 100644 --- a/thrift/lib/cpp2/protocol/TableBasedSerializer.h +++ b/thrift/lib/cpp2/protocol/TableBasedSerializer.h @@ -658,7 +658,7 @@ void readList( using traits = std::iterator_traits; using cat = typename traits::iterator_category; if (folly::reserve_if_available(out, listSize) || - std::is_same::value) { + std::is_same_v) { while (listSize--) { consumeListElem(context, object, reader); } diff --git a/thrift/lib/cpp2/protocol/Traits.h b/thrift/lib/cpp2/protocol/Traits.h index 8a84347cdc1..31eaf3f1c59 100644 --- a/thrift/lib/cpp2/protocol/Traits.h +++ b/thrift/lib/cpp2/protocol/Traits.h @@ -44,7 +44,7 @@ struct protocol_type_ { // clang-format off template static constexpr protocol::TType apply = - std::is_same::value ? protocol::TType::T_BOOL : + std::is_same_v ? protocol::TType::T_BOOL : sizeof(Type) == 1 ? protocol::TType::T_BYTE : sizeof(Type) == 2 ? protocol::TType::T_I16 : sizeof(Type) == 4 ? protocol::TType::T_I32 : diff --git a/thrift/lib/cpp2/protocol/VirtualProtocol.h b/thrift/lib/cpp2/protocol/VirtualProtocol.h index f55e6eeeb5e..3d1080ae34f 100644 --- a/thrift/lib/cpp2/protocol/VirtualProtocol.h +++ b/thrift/lib/cpp2/protocol/VirtualProtocol.h @@ -92,9 +92,8 @@ class VirtualReader : public VirtualReaderBase { template < typename... Args, - typename std::enable_if< - std::is_constructible::value, - bool>::type = false> + std::enable_if_t, bool> = + false> explicit VirtualReader(Args&&... args) : protocol_(std::forward(args)...) {} ~VirtualReader() override {} diff --git a/thrift/lib/cpp2/protocol/detail/index.h b/thrift/lib/cpp2/protocol/detail/index.h index 1251d3cba4d..ff2c100348e 100644 --- a/thrift/lib/cpp2/protocol/detail/index.h +++ b/thrift/lib/cpp2/protocol/detail/index.h @@ -393,7 +393,7 @@ constexpr auto hasIndexSupport(long) { template constexpr auto hasIndexSupport(int) -> decltype(Protocol::ProtocolWriter::kHasIndexSupport()) { - return !std::is_base_of::value && + return !std::is_base_of_v && Protocol::ProtocolWriter::kHasIndexSupport(); } diff --git a/thrift/lib/cpp2/protocol/detail/protocol_methods.h b/thrift/lib/cpp2/protocol/detail/protocol_methods.h index b1324df758c..84bd3675e20 100644 --- a/thrift/lib/cpp2/protocol/detail/protocol_methods.h +++ b/thrift/lib/cpp2/protocol/detail/protocol_methods.h @@ -172,7 +172,7 @@ constexpr bool set_emplace_hint_is_invocable_v = folly::is_invocable_v< typename T::value_type>; template -typename std::enable_if>::type +std::enable_if_t> deserialize_known_length_map( Map& map, std::uint32_t map_size, @@ -202,9 +202,8 @@ deserialize_known_length_map( } template -typename std::enable_if< - !sorted_unique_constructible_v && - map_emplace_hint_is_invocable_v>::type +std::enable_if_t< + !sorted_unique_constructible_v && map_emplace_hint_is_invocable_v> deserialize_known_length_map( Map& map, std::uint32_t map_size, @@ -222,9 +221,9 @@ deserialize_known_length_map( } template -typename std::enable_if< +std::enable_if_t< !sorted_unique_constructible_v && - !map_emplace_hint_is_invocable_v>::type + !map_emplace_hint_is_invocable_v> deserialize_known_length_map( Map& map, std::uint32_t map_size, @@ -238,7 +237,7 @@ deserialize_known_length_map( } template -typename std::enable_if>::type +std::enable_if_t> deserialize_known_length_set( Set& set, std::uint32_t set_size, const ValDeserializer& vr) { if (set_size == 0) { @@ -263,9 +262,8 @@ deserialize_known_length_set( } template -typename std::enable_if< - !sorted_unique_constructible_v && - set_emplace_hint_is_invocable_v>::type +std::enable_if_t< + !sorted_unique_constructible_v && set_emplace_hint_is_invocable_v> deserialize_known_length_set( Set& set, std::uint32_t set_size, const ValDeserializer& vr) { folly::reserve_if_available(set, set_size); @@ -278,9 +276,9 @@ deserialize_known_length_set( } template -typename std::enable_if< +std::enable_if_t< !sorted_unique_constructible_v && - !set_emplace_hint_is_invocable_v>::type + !set_emplace_hint_is_invocable_v> deserialize_known_length_set( Set& set, std::uint32_t set_size, const ValDeserializer& vr) { folly::reserve_if_available(set, set_size); @@ -464,12 +462,12 @@ struct protocol_methods { THRIFT_PROTOCOL_METHODS_REGISTER_RW_COMMON(binary, Type, Binary) template - static typename std::enable_if::type serializedSize( + static std::enable_if_t serializedSize( Protocol& protocol, const Type& in) { return protocol.serializedSizeZCBinary(in); } template - static typename std::enable_if::type serializedSize( + static std::enable_if_t serializedSize( Protocol& protocol, const Type& in) { return protocol.serializedSizeBinary(in); } @@ -484,7 +482,7 @@ struct protocol_methods { template > struct enum_protocol_methods { - static_assert(std::is_enum::value, "must be enum"); + static_assert(std::is_enum_v, "must be enum"); using int_methods = protocol_methods; template @@ -524,8 +522,7 @@ template struct protocol_methods< type_class::integral, Type, - std::enable_if_t::value>> : enum_protocol_methods { -}; + std::enable_if_t>> : enum_protocol_methods {}; /* * List Specialization diff --git a/thrift/lib/cpp2/reflection/demo/json_print.h b/thrift/lib/cpp2/reflection/demo/json_print.h index 4f9975dcb92..efa8da78d18 100644 --- a/thrift/lib/cpp2/reflection/demo/json_print.h +++ b/thrift/lib/cpp2/reflection/demo/json_print.h @@ -27,7 +27,7 @@ template struct printer { static_assert( - !std::is_same::value, + !std::is_same_v, "no static reflection support for the given type" " - did you forget to include the reflection metadata?" " see thrift/lib/cpp2/reflection/reflection.h"); diff --git a/thrift/lib/cpp2/reflection/internal/helpers-inl-pre.h b/thrift/lib/cpp2/reflection/internal/helpers-inl-pre.h index d1d2f28b6e9..b7b0bcf0383 100644 --- a/thrift/lib/cpp2/reflection/internal/helpers-inl-pre.h +++ b/thrift/lib/cpp2/reflection/internal/helpers-inl-pre.h @@ -24,7 +24,7 @@ namespace apache::thrift::detail { template < typename, typename T, - bool StructHasMemberForCriteria = !std::is_same::value> + bool StructHasMemberForCriteria = !std::is_same_v> struct check_struct_has_member_for_criteria { using type = T; diff --git a/thrift/lib/cpp2/reflection/populator.h b/thrift/lib/cpp2/reflection/populator.h index 04e03c2eea8..adf6054f1a9 100644 --- a/thrift/lib/cpp2/reflection/populator.h +++ b/thrift/lib/cpp2/reflection/populator.h @@ -92,12 +92,10 @@ template struct is_smart_pointer> : std::true_type {}; template -using enable_if_smart_pointer = - typename std::enable_if::value>::type; +using enable_if_smart_pointer = std::enable_if_t::value>; template -using disable_if_smart_pointer = - typename std::enable_if::value>::type; +using disable_if_smart_pointer = std::enable_if_t::value>; struct extract_descriptor_fid { template @@ -126,7 +124,7 @@ struct deref> { // unique pointer contains template struct deref> { - using T = typename std::remove_const::type; + using T = std::remove_const_t; static T& clear_and_get(std::shared_ptr& in) { auto t = std::make_shared(); auto ret = t.get(); @@ -287,7 +285,7 @@ struct populator_methods< detail::infer_tag, Type, std::enable_if_t, type::enum_c>>> { - using int_type = typename std::underlying_type::type; + using int_type = std::underlying_type_t; using int_methods = populator_methods, int_type>; template diff --git a/thrift/lib/cpp2/reflection/reflection.h b/thrift/lib/cpp2/reflection/reflection.h index 139cfb51153..09f44707756 100644 --- a/thrift/lib/cpp2/reflection/reflection.h +++ b/thrift/lib/cpp2/reflection/reflection.h @@ -567,9 +567,8 @@ using try_reflect_module = fatal::try_registry_lookup< * @author: Marcelo Juchem */ template -using is_reflectable_module = std::integral_constant< - bool, - !std::is_same, void>::value>; +using is_reflectable_module = std:: + integral_constant, void>>; /** * Gets the reflection metadata tag for the Thrift file where the type `T` is @@ -1397,9 +1396,8 @@ using try_reflect_struct = fatal::try_registry_lookup< * @author: Marcelo Juchem */ template -using is_reflectable_struct = std::integral_constant< - bool, - !std::is_same, void>::value>; +using is_reflectable_struct = std:: + integral_constant, void>>; ////////////////////////////// // SECTION: ENUMERATION API // diff --git a/thrift/lib/cpp2/server/ServerAttribute.h b/thrift/lib/cpp2/server/ServerAttribute.h index 43193167f79..b71dde9e885 100644 --- a/thrift/lib/cpp2/server/ServerAttribute.h +++ b/thrift/lib/cpp2/server/ServerAttribute.h @@ -87,7 +87,7 @@ struct ServerAttributeThreadLocal; */ template using ServerAttributeDynamic = std::conditional_t< - sizeof(T) <= sizeof(std::uint64_t) && std::is_trivially_copyable::value, + sizeof(T) <= sizeof(std::uint64_t) && std::is_trivially_copyable_v, ServerAttributeAtomic, ServerAttributeThreadLocal>; diff --git a/thrift/lib/cpp2/transport/core/TryUtil.h b/thrift/lib/cpp2/transport/core/TryUtil.h index 509da6fce3c..5a3b9928003 100644 --- a/thrift/lib/cpp2/transport/core/TryUtil.h +++ b/thrift/lib/cpp2/transport/core/TryUtil.h @@ -26,7 +26,7 @@ template FOLLY_NODISCARD folly::Try collapseTry( folly::Try>&& arg) noexcept { static_assert( - std::is_nothrow_move_constructible>::value, + std::is_nothrow_move_constructible_v>, "move constructor should not throw"); if (arg.hasException()) { return folly::Try(std::move(arg.exception())); diff --git a/thrift/lib/cpp2/transport/rocket/framing/Serializer.h b/thrift/lib/cpp2/transport/rocket/framing/Serializer.h index 14d09f61872..2b1444ffbfc 100644 --- a/thrift/lib/cpp2/transport/rocket/framing/Serializer.h +++ b/thrift/lib/cpp2/transport/rocket/framing/Serializer.h @@ -41,7 +41,7 @@ class Serializer { // All data in rsocket protocol is transmitted in Big Endian format. template - std::enable_if_t::value, size_t> writeBE(T value) { + std::enable_if_t, size_t> writeBE(T value) { const auto bigEndianValue = folly::Endian::big(value); const uint8_t* bytes = reinterpret_cast(&bigEndianValue); return push(bytes, sizeof(T)); diff --git a/thrift/lib/cpp2/type/detail/Runtime.h b/thrift/lib/cpp2/type/detail/Runtime.h index 4fbfe9c97c0..3c6c58f22a7 100644 --- a/thrift/lib/cpp2/type/detail/Runtime.h +++ b/thrift/lib/cpp2/type/detail/Runtime.h @@ -737,7 +737,7 @@ class BaseDyn : public Dyn, using BaseDerived::derived; template constexpr static bool is_index_type_v = - std::is_same::value || std::is_integral::value; + std::is_same_v || std::is_integral_v; template using if_not_index = std::enable_if_t, R>;