Commit ad89d9ad authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

remove meta

fbshipit-source-id: e4951d42e306b7af6ae595394a3994d6e4235083
parent 807d6c9d
......@@ -9,13 +9,11 @@ add_library(pushmi INTERFACE)
target_include_directories(pushmi INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/meta/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/executors-impl/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/futures-impl/future-executor-interaction/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/networking-ts-impl/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/Catch2/single_include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/meta>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/executors>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/futures>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/net>
......@@ -32,9 +30,6 @@ add_dependencies(pushmi buildSingleHeader)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/meta/include/
DESTINATION include/meta)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/executors-impl/include/
DESTINATION include/executors)
......
......@@ -21,9 +21,6 @@ endfunction()
set(header_files
# keep in inclusion order
"${CMAKE_CURRENT_SOURCE_DIR}/external/meta/include/meta/meta_fwd.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/external/meta/include/meta/meta.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/detail/if_constexpr.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/detail/concept_def.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/pushmi/traits.h"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -77,7 +77,7 @@ class deferred<detail::erase_deferred_t, E> {
PUSHMI_TEMPLATE(class Wrapped)
(requires SenderTo<wrapped_t<Wrapped>, any_none<E>, is_none<>>)
explicit deferred(Wrapped obj) noexcept(insitu<Wrapped>())
: deferred{std::move(obj), meta::bool_<insitu<Wrapped>()>{}} {}
: deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~deferred() {
vptr_->op_(data_, nullptr);
}
......
......@@ -37,11 +37,11 @@ PUSHMI_PP_IGNORE_CXX2A_COMPAT_BEGIN
#endif
#ifdef __clang__
#define PUSHMI_PP_IS_SAME(A, B) __is_same(A, B)
#define PUSHMI_PP_IS_SAME(...) __is_same(__VA_ARGS__)
#elif defined(__GNUC__) && __GNUC__ >= 6
#define PUSHMI_PP_IS_SAME(A, B) __is_same_as(A, B)
#define PUSHMI_PP_IS_SAME(...) __is_same_as(__VA_ARGS__)
#else
#define PUSHMI_PP_IS_SAME(A, B) std::is_same<A, B>::value
#define PUSHMI_PP_IS_SAME(...) std::is_same<__VA_ARGS__>::value
#endif
#if __COUNTER__ != __COUNTER__
......@@ -478,6 +478,10 @@ PUSHMI_PP_IGNORE_CXX2A_COMPAT_BEGIN
#endif
namespace pushmi {
template <bool B>
using bool_ = std::integral_constant<bool, B>;
namespace concepts {
namespace detail {
template <class>
......@@ -504,7 +508,7 @@ struct And {
static constexpr bool impl(std::false_type) noexcept { return false; }
static constexpr bool impl(std::true_type) noexcept { return (bool) U{}; }
explicit constexpr operator bool() const noexcept {
return And::impl(std::integral_constant<bool, (bool) T{}>{});
return And::impl(bool_<(bool) T{}>{});
}
constexpr auto operator!() const noexcept {
return Not<And>{};
......
......@@ -8,8 +8,6 @@
#include <functional>
#include <meta/meta.hpp>
#include "../traits.h"
#include "../forwards.h"
......@@ -19,22 +17,43 @@ namespace detail {
struct placeholder;
#if (defined(__clang__) || defined(__GNUC__)) &&\
__has_builtin(__type_pack_element)
#define PUSHMI_TYPE_PACK_ELEMENT(...) \
__type_pack_element<__VA_ARGS__>
#else
template <std::size_t I, class... Args>
struct type_pack_element {
};
template <std::size_t I, class A, class... Args>
struct type_pack_element<I, A, Args...> : type_pack_element<I - 1, Args...> {
};
template <class A, class... Args>
struct type_pack_element<0, A, Args...> {
using type = A;
};
#define PUSHMI_TYPE_PACK_ELEMENT(...) \
typename type_pack_element<__VA_ARGS__>::type
#endif
template <class T, class Args, class = void>
struct substitute {
using type = T;
};
template <std::size_t I, class Args>
struct substitute<placeholder[I], Args>
: meta::lazy::let<
meta::defer<std::decay_t, meta::lazy::at<Args, meta::size_t<I-1>>>> {
template <std::size_t I, class... Args>
struct substitute<placeholder[I], typelist<Args...>,
void_t<PUSHMI_TYPE_PACK_ELEMENT(I-1, Args...)>>
: std::decay<PUSHMI_TYPE_PACK_ELEMENT(I-1, Args...)> {
};
template <std::size_t I, class Args>
struct substitute<placeholder(&&)[I], Args>
: meta::lazy::at<Args, meta::size_t<I-1>> {
template <std::size_t I, class... Args>
struct substitute<placeholder(&&)[I], typelist<Args...>,
void_t<PUSHMI_TYPE_PACK_ELEMENT(I-1, Args...)>> {
using type = PUSHMI_TYPE_PACK_ELEMENT(I-1, Args...);
};
template <template <class...> class R, class... Ts, class Args>
struct substitute<R<Ts...>, Args, meta::void_<R<meta::_t<substitute<Ts, Args>>...>>> {
using type = R<meta::_t<substitute<Ts, Args>>...>;
struct substitute<R<Ts...>, Args,
void_t<R<typename substitute<Ts, Args>::type...>>> {
using type = R<typename substitute<Ts, Args>::type...>;
};
template <class Fn, class Requirements>
......@@ -44,14 +63,16 @@ struct constrained_fn : Fn {
PUSHMI_TEMPLATE (class... Ts)
(requires Invocable<Fn&, Ts...> &&
(bool)meta::_t<substitute<Requirements, meta::list<Ts...>>>{})
decltype(auto) operator()(Ts&&... ts) noexcept(noexcept(std::declval<Fn&>()((Ts&&) ts...))) {
(bool)typename substitute<Requirements, typelist<Ts...>>::type{})
decltype(auto) operator()(Ts&&... ts)
noexcept(noexcept(std::declval<Fn&>()((Ts&&) ts...))) {
return static_cast<Fn&>(*this)((Ts&&) ts...);
}
PUSHMI_TEMPLATE (class... Ts)
(requires Invocable<const Fn&, Ts...> &&
(bool)meta::_t<substitute<Requirements, meta::list<Ts...>>>{})
decltype(auto) operator()(Ts&&... ts) const noexcept(noexcept(std::declval<const Fn&>()((Ts&&) ts...))) {
(bool)typename substitute<Requirements, typelist<Ts...>>::type{})
decltype(auto) operator()(Ts&&... ts) const
noexcept(noexcept(std::declval<const Fn&>()((Ts&&) ts...))) {
return static_cast<const Fn&>(*this)((Ts&&) ts...);
}
};
......
......@@ -107,7 +107,7 @@ public:
PUSHMI_TEMPLATE(class Wrapped)
(requires FlowSingleReceiver<wrapped_t<Wrapped>, any_none<PE>, V, PE, E>)
explicit flow_single(Wrapped obj) noexcept(insitu<Wrapped>())
: flow_single{std::move(obj), meta::bool_<insitu<Wrapped>()>{}} {}
: flow_single{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~flow_single() {
vptr_->op_(data_, nullptr);
}
......
......@@ -77,7 +77,7 @@ class flow_single_deferred<V, PE, E> {
PUSHMI_TEMPLATE (class Wrapped)
(requires FlowSender<wrapped_t<Wrapped>, is_single<>>)
explicit flow_single_deferred(Wrapped obj) noexcept(insitu<Wrapped>())
: flow_single_deferred{std::move(obj), meta::bool_<insitu<Wrapped>()>{}} {}
: flow_single_deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~flow_single_deferred() {
vptr_->op_(data_, nullptr);
}
......
......@@ -83,7 +83,7 @@ public:
PUSHMI_TEMPLATE(class Wrapped)
(requires NoneReceiver<wrapped_t<Wrapped>, E>)
explicit none(Wrapped obj) noexcept(insitu<Wrapped>())
: none{std::move(obj), meta::bool_<insitu<Wrapped>()>{}} {}
: none{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~none() {
vptr_->op_(data_, nullptr);
}
......
......@@ -6,8 +6,6 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include <meta/meta.hpp>
#include "../deferred.h"
#include "../single_deferred.h"
#include "../detail/functional.h"
......
......@@ -42,14 +42,14 @@ PUSHMI_CONCEPT_DEF(
PUSHMI_CONCEPT_DEF(
template (class T, class... Set)
(concept FoundExactlyOnce)(T, Set...),
sum_v<(std::is_same<T, Set>::value ? 1 : 0)...> == 1
sum_v<(PUSHMI_PP_IS_SAME(T, Set) ? 1 : 0)...> == 1
);
PUSHMI_CONCEPT_DEF(
template (class... PropertyN)
(concept UniqueCategory)(PropertyN...),
all_true_v<FoundExactlyOnce<property_category_t<PropertyN>,
property_category_t<PropertyN>...>...> &&
And<FoundExactlyOnce<property_category_t<PropertyN>,
property_category_t<PropertyN>...>...> &&
And<Property<PropertyN>...>
);
......@@ -60,7 +60,7 @@ struct property_set_element {};
template<class... PropertyN>
struct property_set : detail::property_set_element<PropertyN>... {
static_assert(all_true_v<Property<PropertyN>...>, "property_set only supports types that match the Property concept");
static_assert(and_v<Property<PropertyN>...>, "property_set only supports types that match the Property concept");
static_assert(UniqueCategory<PropertyN...>, "property_set has multiple properties from the same category");
using properties = property_set;
};
......@@ -109,12 +109,11 @@ PUSHMI_CONCEPT_DEF(
// find property in the specified set that matches the category of the property specified.
namespace detail {
template <class PIn, class POut>
POut __property_set_index_fn(property_set_element<POut, property_category_t<PIn>>);
template <class PIn, class POut, class...Ps>
meta::apply<meta::quote<property_set>, meta::replace<meta::list<Ps...>, POut, PIn>>
property_set<std::conditional_t<PUSHMI_PP_IS_SAME(Ps, PIn), POut, Ps>...>
__property_set_insert_fn(property_set<Ps...>, property_set_element<POut, property_category_t<PIn>>);
template <class PIn, class...Ps>
......@@ -124,6 +123,15 @@ template <class PS, class P>
using property_set_insert_one_t =
decltype(detail::__property_set_insert_fn<P>(PS{}, PS{}));
template <class PS0, class>
struct property_set_insert {
using type = PS0;
};
template <class PS0, class P, class... P1>
struct property_set_insert<PS0, property_set<P, P1...>>
: property_set_insert<property_set_insert_one_t<PS0, P>, property_set<P1...>>
{};
} // namespace detail
template <class PS, class P>
......@@ -138,14 +146,9 @@ using property_from_category_t =
template <class PS0, class PS1>
using property_set_insert_t =
std::enable_if_t<
typename std::enable_if_t<
PropertySet<PS0> && PropertySet<PS1>,
meta::apply<
meta::quote<property_set>,
meta::fold<
meta::apply<meta::quote<meta::list>, PS1>,
PS0,
meta::quote<detail::property_set_insert_one_t>>>>;
detail::property_set_insert<PS0, PS1>>::type;
// query for properties on types with properties.
......@@ -157,20 +160,20 @@ template<class PIn>
std::false_type property_query_fn(void*);
template<class PS, class... ExpectedN>
struct property_query_impl :
meta::and_c<decltype(property_query_fn<ExpectedN>((properties_t<PS>*)nullptr))::value...> {};
struct property_query_impl : bool_<
and_v<decltype(property_query_fn<ExpectedN>(
(properties_t<PS>*)nullptr))::value...>> {};
} //namespace detail
//template<PUSHMI_TYPE_CONSTRAINT(Properties) PS, PUSHMI_TYPE_CONSTRAINT(Property)... ExpectedN>
template<class PS, class... ExpectedN>
struct property_query
: meta::if_c<
: std::conditional_t<
Properties<PS> && And<Property<ExpectedN>...>,
detail::property_query_impl<PS, ExpectedN...>,
std::false_type> {};
//template<PUSHMI_TYPE_CONSTRAINT(Properties) PS, PUSHMI_TYPE_CONSTRAINT(Property)... ExpectedN>
template<class PS, class... ExpectedN>
PUSHMI_INLINE_VAR constexpr bool property_query_v = property_query<PS, ExpectedN...>::value;
PUSHMI_INLINE_VAR constexpr bool property_query_v =
property_query<PS, ExpectedN...>::value;
} // namespace pushmi
......@@ -110,7 +110,7 @@ public:
PUSHMI_TEMPLATE(class Wrapped)
(requires SingleReceiver<wrapped_t<Wrapped>, V, E>)
explicit single(Wrapped obj) noexcept(insitu<Wrapped>())
: single{std::move(obj), meta::bool_<insitu<Wrapped>()>{}} {
: single{std::move(obj), bool_<insitu<Wrapped>()>{}} {
check<Wrapped>();
}
~single() {
......
......@@ -77,7 +77,7 @@ class any_single_deferred {
PUSHMI_TEMPLATE(class Wrapped)
(requires SenderTo<wrapped_t<Wrapped>, single<V, E>, is_single<>>)
explicit any_single_deferred(Wrapped obj) noexcept(insitu<Wrapped>())
: any_single_deferred{std::move(obj), meta::bool_<insitu<Wrapped>()>{}} {}
: any_single_deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
~any_single_deferred() {
vptr_->op_(data_, nullptr);
}
......@@ -138,7 +138,7 @@ class single_deferred_2 {
template <class A, class B>
using single_deferred_base =
meta::if_c<
std::conditional_t<
(bool)Sender<A, is_single<>>,
single_deferred_2<A, B>,
any_single_deferred<A, B>>;
......
......@@ -94,7 +94,7 @@ class any_time_single_deferred {
PUSHMI_TEMPLATE (class Wrapped)
(requires TimeSenderTo<wrapped_t<Wrapped>, single<V, E>>)
explicit any_time_single_deferred(Wrapped obj) noexcept(insitu<Wrapped>())
: any_time_single_deferred{std::move(obj), meta::bool_<insitu<Wrapped>()>{}} {
: any_time_single_deferred{std::move(obj), bool_<insitu<Wrapped>()>{}} {
}
~any_time_single_deferred() {
vptr_->op_(data_, nullptr);
......@@ -175,7 +175,7 @@ class time_single_deferred_2 {
template <class A, class B, class C>
using time_single_deferred_base =
meta::if_c<
std::conditional_t<
(bool)TimeSender<A, is_single<>>,
time_single_deferred_2<A, B, C>,
any_time_single_deferred<A, B, C>>;
......
......@@ -7,51 +7,52 @@
#include <functional>
#include <type_traits>
#include <meta/meta.hpp>
#include "detail/concept_def.h"
namespace pushmi {
namespace detail {
template <bool...>
struct bools;
}
#if __cpp_fold_expressions >= 201603
template <bool...Bs>
PUSHMI_INLINE_VAR constexpr bool all_true_v = (Bs &&...);
#else
template <bool...Bs>
PUSHMI_INLINE_VAR constexpr bool all_true_v =
std::is_same<detail::bools<Bs..., true>, detail::bools<true, Bs...>>::value;
#endif
PUSHMI_INLINE_VAR constexpr bool and_v = (Bs &&...);
#if __cpp_fold_expressions >= 201603
template <bool...Bs>
PUSHMI_INLINE_VAR constexpr bool any_true_v = (Bs ||...);
#else
template <bool...Bs>
PUSHMI_INLINE_VAR constexpr bool any_true_v =
!std::is_same<detail::bools<Bs..., false>, detail::bools<false, Bs...>>::value;
#endif
PUSHMI_INLINE_VAR constexpr bool or_v = (Bs ||...);
#if __cpp_fold_expressions >= 201603
template <int...Is>
PUSHMI_INLINE_VAR constexpr int sum_v = (Is +...);
#else
template <std::size_t N>
constexpr int sum_impl(int const (&rgi)[N], int i = 0, int state = 0) noexcept {
return i == N ? state : sum_impl(rgi, i+1, state + rgi[i]);
}
template <int... Is>
constexpr int sum_impl() noexcept {
using RGI = int[sizeof...(Is)];
return sum_impl(RGI{Is...});
}
namespace detail {
template <bool...>
struct bools;
template <std::size_t N>
constexpr int sum_impl(int const (&rgi)[N], int i = 0, int state = 0) noexcept {
return i == N ? state : sum_impl(rgi, i+1, state + rgi[i]);
}
template <int... Is>
constexpr int sum_impl() noexcept {
using RGI = int[sizeof...(Is)];
return sum_impl(RGI{Is...});
}
} // namespace detail
template <bool...Bs>
PUSHMI_INLINE_VAR constexpr bool and_v =
PUSHMI_PP_IS_SAME(detail::bools<Bs..., true>, detail::bools<true, Bs...>);
template <bool...Bs>
PUSHMI_INLINE_VAR constexpr bool or_v =
!PUSHMI_PP_IS_SAME(detail::bools<Bs..., false>, detail::bools<false, Bs...>);
template <int...Is>
PUSHMI_INLINE_VAR constexpr int sum_v = sum_impl<Is...>();
PUSHMI_INLINE_VAR constexpr int sum_v = detail::sum_impl<Is...>();
#endif
template <class...>
struct typelist;
template <class...>
using void_t = void;
template <class T>
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
......@@ -78,13 +79,13 @@ PUSHMI_CONCEPT_DEF(
PUSHMI_CONCEPT_DEF(
template (bool...Bs)
(concept And)(Bs...),
all_true_v<Bs...>
and_v<Bs...>
);
PUSHMI_CONCEPT_DEF(
template (bool...Bs)
(concept Or)(Bs...),
any_true_v<Bs...>
or_v<Bs...>
);
PUSHMI_CONCEPT_DEF(
......@@ -180,7 +181,6 @@ PUSHMI_CONCEPT_DEF(
#if __cpp_lib_invoke >= 201411
using std::invoke;
using std::invoke_result;
using std::invoke_result_t;
#else
PUSHMI_TEMPLATE (class F, class...As)
......@@ -202,8 +202,6 @@ decltype(auto) invoke(F f, As&&...as)
template <class F, class...As>
using invoke_result_t =
decltype(pushmi::invoke(std::declval<F>(), std::declval<As>()...));
template <class F, class...As>
struct invoke_result : meta::defer<invoke_result_t, F, As...> {};
#endif
PUSHMI_CONCEPT_DEF(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment