@@ -59,12 +59,11 @@ struct move_to_unique_ptr_fn;
5959struct assign_from_unique_ptr_fn ;
6060struct union_value_unsafe_fn ;
6161struct is_non_optional_field_set_manually_or_by_serializer_fn ;
62- template <typename T, typename U>
63- using EnableIfImplicit = std::enable_if_t <
64- std::is_same<
65- std::add_const_t <std::remove_reference_t <U>>,
66- std::remove_reference_t <T>>{} &&
67- !(std::is_rvalue_reference<T>{} && std::is_lvalue_reference<U>{})>;
62+ template <typename U, typename T>
63+ concept ImplicitlyBindableTo = std::is_same_v<
64+ std::add_const_t <std::remove_reference_t <U>>,
65+ std::remove_reference_t <T>> &&
66+ !(std::is_rvalue_reference_v<T> && std::is_lvalue_reference_v<U>);
6867
6968} // namespace detail
7069
@@ -102,9 +101,7 @@ class field_ref {
102101 const uint8_t bit_index = 0 ) noexcept
103102 : value_(value), bitref_(is_set, bit_index) {}
104103
105- template <
106- typename U,
107- typename = apache::thrift::detail::EnableIfImplicit<T, U>>
104+ template <detail::ImplicitlyBindableTo<T> U>
108105 FOLLY_ERASE /* implicit */ field_ref(const field_ref<U>& other) noexcept
109106 : value_(other.value_), bitref_(other.bitref_) {}
110107
@@ -348,9 +345,7 @@ class optional_field_ref {
348345 const uint8_t bit_index = 0 ) noexcept
349346 : value_(value), bitref_(is_set, bit_index) {}
350347
351- template <
352- typename U,
353- typename = apache::thrift::detail::EnableIfImplicit<T, U>>
348+ template <detail::ImplicitlyBindableTo<T> U>
354349 FOLLY_ERASE /* implicit */ optional_field_ref(
355350 const optional_field_ref<U>& other) noexcept
356351 : value_(other.value_), bitref_(other.bitref_) {}
@@ -690,9 +685,7 @@ class optional_boxed_field_ref {
690685 FOLLY_ERASE explicit optional_boxed_field_ref (T value) noexcept
691686 : value_(value) {}
692687
693- template <
694- typename U,
695- typename = apache::thrift::detail::EnableIfImplicit<T, U>>
688+ template <detail::ImplicitlyBindableTo<T> U>
696689 FOLLY_ERASE /* implicit */
697690 optional_boxed_field_ref (const optional_boxed_field_ref<U>& other) noexcept
698691 : value_(other.value_) {}
@@ -1001,9 +994,7 @@ class intern_boxed_field_ref {
1001994 const uint8_t bit_index = 0 ) noexcept
1002995 : value_(value), get_default_(get_default), bitref_(is_set, bit_index) {}
1003996
1004- template <
1005- typename U,
1006- typename = apache::thrift::detail::EnableIfImplicit<T, U>>
997+ template <detail::ImplicitlyBindableTo<T> U>
1007998 FOLLY_ERASE /* implicit */ intern_boxed_field_ref(
1008999 const intern_boxed_field_ref<U>& other) noexcept
10091000 : value_(other.value_), bitref_(other.bitref_) {}
@@ -1227,9 +1218,7 @@ class terse_intern_boxed_field_ref {
12271218 T value, get_default_t get_default) noexcept
12281219 : value_(value), get_default_(get_default) {}
12291220
1230- template <
1231- typename U,
1232- typename = apache::thrift::detail::EnableIfImplicit<T, U>>
1221+ template <detail::ImplicitlyBindableTo<T> U>
12331222 FOLLY_ERASE /* implicit */ terse_intern_boxed_field_ref(
12341223 const terse_intern_boxed_field_ref<U>& other) noexcept
12351224 : value_(other.value_) {}
@@ -1606,9 +1595,7 @@ class required_field_ref {
16061595 FOLLY_ERASE explicit required_field_ref (reference_type value) noexcept
16071596 : value_(value) {}
16081597
1609- template <
1610- typename U,
1611- typename = apache::thrift::detail::EnableIfImplicit<T, U>>
1598+ template <detail::ImplicitlyBindableTo<T> U>
16121599 FOLLY_ERASE /* implicit */ required_field_ref(
16131600 const required_field_ref<U>& other) noexcept
16141601 : value_(other.value_) {}
@@ -2118,9 +2105,7 @@ class terse_field_ref {
21182105
21192106 FOLLY_ERASE terse_field_ref (reference_type value) noexcept : value_(value) {}
21202107
2121- template <
2122- typename U,
2123- typename = apache::thrift::detail::EnableIfImplicit<T, U>>
2108+ template <detail::ImplicitlyBindableTo<T> U>
21242109 FOLLY_ERASE /* implicit */ terse_field_ref(
21252110 const terse_field_ref<U>& other) noexcept
21262111 : value_(other.value_) {}
0 commit comments