Skip to content

Commit

Permalink
move folly::is_instantiation_of_v out of detail
Browse files Browse the repository at this point in the history
Summary: since we want a publicly facing concept, remove detail

Reviewed By: jagill, yfeldblum

Differential Revision: D60284223

fbshipit-source-id: 38c3fc12991d42891342f9cdb89814fd4d1f2420
  • Loading branch information
DenisYaroshevskiy authored and facebook-github-bot committed Jul 31, 2024
1 parent 26bae83 commit 3cfdae0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion folly/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ using DispatchOf = Dispatch<
// `Function` there refers to the instantion and not the template.
template <typename T>
constexpr bool is_instantiation_of_folly_function_v =
detail::is_instantiation_of_v<Function, T>;
is_instantiation_of_v<Function, T>;

} // namespace function
} // namespace detail
Expand Down
2 changes: 1 addition & 1 deletion folly/Replaceable.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ struct is_convertible_from_replaceable
} // namespace replaceable_detail

template <class T>
using is_replaceable = detail::is_instantiation_of<Replaceable, T>;
using is_replaceable = is_instantiation_of<Replaceable, T>;

// Function to make a Replaceable with a type deduced from its input
template <class T>
Expand Down
4 changes: 0 additions & 4 deletions folly/Traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ inline constexpr bool is_bounded_array_v<T[S]> = true;
template <typename T>
struct is_bounded_array : std::bool_constant<is_bounded_array_v<T>> {};

namespace detail {

/// is_instantiation_of_v
/// is_instantiation_of
///
Expand All @@ -176,8 +174,6 @@ template <template <typename...> class C, typename... T>
struct is_instantiation_of
: std::bool_constant<is_instantiation_of_v<C, T...>> {};

} // namespace detail

/// member_pointer_traits
///
/// For a member-pointer, reveals its constituent member-type and object-type.
Expand Down
2 changes: 1 addition & 1 deletion folly/container/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace folly {

namespace array_detail {
template <class T>
using is_ref_wrapper = detail::is_instantiation_of<std::reference_wrapper, T>;
using is_ref_wrapper = is_instantiation_of<std::reference_wrapper, T>;

template <typename T>
using not_ref_wrapper =
Expand Down
4 changes: 2 additions & 2 deletions folly/container/sorted_vector_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ inline void swap(

template <typename T>
inline constexpr bool is_sorted_vector_set_v =
detail::is_instantiation_of_v<sorted_vector_set, T>;
is_instantiation_of_v<sorted_vector_set, T>;

template <typename T>
struct is_sorted_vector_set : std::bool_constant<is_sorted_vector_set_v<T>> {};
Expand Down Expand Up @@ -1618,7 +1618,7 @@ inline void swap(

template <typename T>
inline constexpr bool is_sorted_vector_map_v =
detail::is_instantiation_of_v<sorted_vector_map, T>;
is_instantiation_of_v<sorted_vector_map, T>;

template <typename T>
struct is_sorted_vector_map : std::bool_constant<is_sorted_vector_map_v<T>> {};
Expand Down
7 changes: 3 additions & 4 deletions folly/coro/Traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ using remove_reference_wrapper_t = typename remove_reference_wrapper<T>::type;
namespace detail {

template <typename T>
inline constexpr bool is_coroutine_handle_v =
folly::detail::is_instantiation_of_v< //
coroutine_handle,
T>;
inline constexpr bool is_coroutine_handle_v = folly::is_instantiation_of_v< //
coroutine_handle,
T>;

} // namespace detail

Expand Down
2 changes: 1 addition & 1 deletion folly/fibers/async/Async.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ inline void init_await(Async<void>&& async) {

// is_async
template <typename T>
constexpr bool is_async_v = folly::detail::is_instantiation_of_v<Async, T>;
constexpr bool is_async_v = folly::is_instantiation_of_v<Async, T>;

// async_inner_type
template <typename T>
Expand Down
8 changes: 4 additions & 4 deletions folly/test/TraitsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,13 @@ TEST(Traits, isBoundedArrayV) {
}

TEST(Traits, isInstantiationOfV) {
EXPECT_TRUE((detail::is_instantiation_of_v<A, A<int>>));
EXPECT_FALSE((detail::is_instantiation_of_v<A, B>));
EXPECT_TRUE((is_instantiation_of_v<A, A<int>>));
EXPECT_FALSE((is_instantiation_of_v<A, B>));
}

TEST(Traits, isInstantiationOf) {
EXPECT_TRUE((detail::is_instantiation_of<A, A<int>>::value));
EXPECT_FALSE((detail::is_instantiation_of<A, B>::value));
EXPECT_TRUE((is_instantiation_of<A, A<int>>::value));
EXPECT_FALSE((is_instantiation_of<A, B>::value));
}

TEST(Traits, member_pointer_traits_data) {
Expand Down

0 comments on commit 3cfdae0

Please sign in to comment.