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

slight improvement to the "broken subsumption" workaround

fbshipit-source-id: 0901852e14521df7f5f8ed6ce338cbc9cfceb279
parent ad89d9ad
This diff is collapsed.
...@@ -458,7 +458,7 @@ PUSHMI_PP_IGNORE_CXX2A_COMPAT_BEGIN ...@@ -458,7 +458,7 @@ PUSHMI_PP_IGNORE_CXX2A_COMPAT_BEGIN
#if __cpp_concepts #if __cpp_concepts
#define PUSHMI_BROKEN_SUBSUMPTION(...) __VA_ARGS__ // BUGBUG #define PUSHMI_BROKEN_SUBSUMPTION(...)
#define PUSHMI_TYPE_CONSTRAINT(...) __VA_ARGS__ #define PUSHMI_TYPE_CONSTRAINT(...) __VA_ARGS__
#else #else
#define PUSHMI_BROKEN_SUBSUMPTION(...) __VA_ARGS__ #define PUSHMI_BROKEN_SUBSUMPTION(...) __VA_ARGS__
...@@ -467,13 +467,13 @@ PUSHMI_PP_IGNORE_CXX2A_COMPAT_BEGIN ...@@ -467,13 +467,13 @@ PUSHMI_PP_IGNORE_CXX2A_COMPAT_BEGIN
#if __cpp_concepts #if __cpp_concepts
#define PUSHMI_PP_CONSTRAINED_USING(REQUIRES, NAME, TYPE) \ #define PUSHMI_PP_CONSTRAINED_USING(REQUIRES, NAME, ...) \
requires REQUIRES \ requires REQUIRES \
using NAME TYPE; \ using NAME __VA_ARGS__; \
/**/ /**/
#else #else
#define PUSHMI_PP_CONSTRAINED_USING(REQUIRES, NAME, TYPE) \ #define PUSHMI_PP_CONSTRAINED_USING(REQUIRES, NAME, ...) \
using NAME std::enable_if_t<bool(REQUIRES), TYPE>; \ using NAME std::enable_if_t<bool(REQUIRES), __VA_ARGS__>; \
/**/ /**/
#endif #endif
...@@ -520,8 +520,7 @@ struct And { ...@@ -520,8 +520,7 @@ struct And {
}; };
} // namespace detail } // namespace detail
} // namespace concepts } // namespace concepts
template <class T>
PUSHMI_INLINE_VAR constexpr bool typename_ = true;
template <class T> template <class T>
constexpr bool implicitly_convertible_to(T) { constexpr bool implicitly_convertible_to(T) {
return true; return true;
......
...@@ -197,12 +197,12 @@ inline auto make_none() -> none<> { ...@@ -197,12 +197,12 @@ inline auto make_none() -> none<> {
return {}; return {};
} }
PUSHMI_TEMPLATE(class EF) PUSHMI_TEMPLATE(class EF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not defer::Receiver<EF> && not defer::Invocable<EF&>)) (requires defer::True<> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<EF> && not defer::Invocable<EF&>))
auto make_none(EF ef) -> none<EF, ignoreDF> { auto make_none(EF ef) -> none<EF, ignoreDF> {
return none<EF, ignoreDF>{std::move(ef)}; return none<EF, ignoreDF>{std::move(ef)};
} }
PUSHMI_TEMPLATE(class DF) PUSHMI_TEMPLATE(class DF)
(requires defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>)) (requires defer::True<> && defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>))
auto make_none(DF df) -> none<abortEF, DF> { auto make_none(DF df) -> none<abortEF, DF> {
return none<abortEF, DF>{std::move(df)}; return none<abortEF, DF>{std::move(df)};
} }
...@@ -212,7 +212,7 @@ auto make_none(EF ef, DF df) -> none<EF, DF> { ...@@ -212,7 +212,7 @@ auto make_none(EF ef, DF df) -> none<EF, DF> {
return {std::move(ef), std::move(df)}; return {std::move(ef), std::move(df)};
} }
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires defer::Receiver<Data, is_none<>> && not defer::Receiver<Data, is_single<>>) (requires defer::True<> && defer::Receiver<Data, is_none<>> && not defer::Receiver<Data, is_single<>>)
auto make_none(Data d) -> none<Data, passDEF, passDDF> { auto make_none(Data d) -> none<Data, passDEF, passDDF> {
return none<Data, passDEF, passDDF>{std::move(d)}; return none<Data, passDEF, passDDF>{std::move(d)};
} }
...@@ -241,11 +241,11 @@ auto make_none(Data d, DEF ef, DDF df) -> none<Data, DEF, DDF> { ...@@ -241,11 +241,11 @@ auto make_none(Data d, DEF ef, DDF df) -> none<Data, DEF, DDF> {
none() -> none<>; none() -> none<>;
PUSHMI_TEMPLATE(class EF) PUSHMI_TEMPLATE(class EF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not defer::Receiver<EF> && not defer::Invocable<EF&>)) (requires defer::True<> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<EF> && not defer::Invocable<EF&>))
none(EF) -> none<EF, ignoreDF>; none(EF) -> none<EF, ignoreDF>;
PUSHMI_TEMPLATE(class DF) PUSHMI_TEMPLATE(class DF)
(requires defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>)) (requires defer::True<> && defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>))
none(DF) -> none<abortEF, DF>; none(DF) -> none<abortEF, DF>;
PUSHMI_TEMPLATE(class EF, class DF) PUSHMI_TEMPLATE(class EF, class DF)
...@@ -253,7 +253,7 @@ PUSHMI_TEMPLATE(class EF, class DF) ...@@ -253,7 +253,7 @@ PUSHMI_TEMPLATE(class EF, class DF)
none(EF, DF) -> none<EF, DF>; none(EF, DF) -> none<EF, DF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires defer::Receiver<Data, is_none<>> && not defer::Receiver<Data, is_single<>>) (requires defer::True<> && defer::Receiver<Data, is_none<>> && not defer::Receiver<Data, is_single<>>)
none(Data) -> none<Data, passDEF, passDDF>; none(Data) -> none<Data, passDEF, passDDF>;
PUSHMI_TEMPLATE(class Data, class DEF) PUSHMI_TEMPLATE(class Data, class DEF)
......
...@@ -282,7 +282,7 @@ inline auto make_single() -> single<> { ...@@ -282,7 +282,7 @@ inline auto make_single() -> single<> {
return {}; return {};
} }
PUSHMI_TEMPLATE(class VF) PUSHMI_TEMPLATE(class VF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not defer::Receiver<VF> && not defer::Invocable<VF&>)) (requires defer::True<> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<VF> && not defer::Invocable<VF&>))
auto make_single(VF vf) -> single<VF, abortEF, ignoreDF> { auto make_single(VF vf) -> single<VF, abortEF, ignoreDF> {
return single<VF, abortEF, ignoreDF>{std::move(vf)}; return single<VF, abortEF, ignoreDF>{std::move(vf)};
} }
...@@ -291,17 +291,17 @@ auto make_single(on_error_fn<EFN...> ef) -> single<ignoreVF, on_error_fn<EFN...> ...@@ -291,17 +291,17 @@ auto make_single(on_error_fn<EFN...> ef) -> single<ignoreVF, on_error_fn<EFN...>
return single<ignoreVF, on_error_fn<EFN...>, ignoreDF>{std::move(ef)}; return single<ignoreVF, on_error_fn<EFN...>, ignoreDF>{std::move(ef)};
} }
PUSHMI_TEMPLATE(class DF) PUSHMI_TEMPLATE(class DF)
(requires defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>)) (requires defer::True<> && defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>))
auto make_single(DF df) -> single<ignoreVF, abortEF, DF> { auto make_single(DF df) -> single<ignoreVF, abortEF, DF> {
return single<ignoreVF, abortEF, DF>{std::move(df)}; return single<ignoreVF, abortEF, DF>{std::move(df)};
} }
PUSHMI_TEMPLATE(class VF, class EF) PUSHMI_TEMPLATE(class VF, class EF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not defer::Receiver<VF> && not defer::Invocable<EF&>)) (requires defer::True<> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<VF> && not defer::Invocable<EF&>))
auto make_single(VF vf, EF ef) -> single<VF, EF, ignoreDF> { auto make_single(VF vf, EF ef) -> single<VF, EF, ignoreDF> {
return {std::move(vf), std::move(ef)}; return {std::move(vf), std::move(ef)};
} }
PUSHMI_TEMPLATE(class EF, class DF) PUSHMI_TEMPLATE(class EF, class DF)
(requires defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<EF>)) (requires defer::True<> && defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<EF>))
auto make_single(EF ef, DF df) -> single<ignoreVF, EF, DF> { auto make_single(EF ef, DF df) -> single<ignoreVF, EF, DF> {
return {std::move(ef), std::move(df)}; return {std::move(ef), std::move(df)};
} }
...@@ -311,12 +311,12 @@ auto make_single(VF vf, EF ef, DF df) -> single<VF, EF, DF> { ...@@ -311,12 +311,12 @@ auto make_single(VF vf, EF ef, DF df) -> single<VF, EF, DF> {
return {std::move(vf), std::move(ef), std::move(df)}; return {std::move(vf), std::move(ef), std::move(df)};
} }
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires defer::Receiver<Data, is_single<>>) (requires defer::True<> && defer::Receiver<Data, is_single<>>)
auto make_single(Data d) -> single<Data, passDVF, passDEF, passDDF> { auto make_single(Data d) -> single<Data, passDVF, passDEF, passDDF> {
return single<Data, passDVF, passDEF, passDDF>{std::move(d)}; return single<Data, passDVF, passDEF, passDDF>{std::move(d)};
} }
PUSHMI_TEMPLATE(class Data, class DVF) PUSHMI_TEMPLATE(class Data, class DVF)
(requires defer::Receiver<Data, is_single<>> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Invocable<DVF&, Data&>)) (requires defer::True<> && defer::Receiver<Data, is_single<>> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Invocable<DVF&, Data&>))
auto make_single(Data d, DVF vf) -> single<Data, DVF, passDEF, passDDF> { auto make_single(Data d, DVF vf) -> single<Data, DVF, passDEF, passDDF> {
return {std::move(d), std::move(vf)}; return {std::move(d), std::move(vf)};
} }
...@@ -327,7 +327,7 @@ auto make_single(Data d, on_error_fn<DEFN...> ef) -> ...@@ -327,7 +327,7 @@ auto make_single(Data d, on_error_fn<DEFN...> ef) ->
return {std::move(d), std::move(ef)}; return {std::move(d), std::move(ef)};
} }
PUSHMI_TEMPLATE(class Data, class DDF) PUSHMI_TEMPLATE(class Data, class DDF)
(requires defer::Receiver<Data, is_single<>> && defer::Invocable<DDF&, Data&>) (requires defer::True<> && defer::Receiver<Data, is_single<>> && defer::Invocable<DDF&, Data&>)
auto make_single(Data d, DDF df) -> single<Data, passDVF, passDEF, DDF> { auto make_single(Data d, DDF df) -> single<Data, passDVF, passDEF, DDF> {
return {std::move(d), std::move(df)}; return {std::move(d), std::move(df)};
} }
...@@ -353,22 +353,22 @@ auto make_single(Data d, DVF vf, DEF ef, DDF df) -> single<Data, DVF, DEF, DDF> ...@@ -353,22 +353,22 @@ auto make_single(Data d, DVF vf, DEF ef, DDF df) -> single<Data, DVF, DEF, DDF>
single() -> single<>; single() -> single<>;
PUSHMI_TEMPLATE(class VF) PUSHMI_TEMPLATE(class VF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not defer::Receiver<VF> && not defer::Invocable<VF&>)) (requires defer::True<> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<VF> && not defer::Invocable<VF&>))
single(VF) -> single<VF, abortEF, ignoreDF>; single(VF) -> single<VF, abortEF, ignoreDF>;
template <class... EFN> template <class... EFN>
single(on_error_fn<EFN...>) -> single<ignoreVF, on_error_fn<EFN...>, ignoreDF>; single(on_error_fn<EFN...>) -> single<ignoreVF, on_error_fn<EFN...>, ignoreDF>;
PUSHMI_TEMPLATE(class DF) PUSHMI_TEMPLATE(class DF)
(requires defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>)) (requires defer::True<> && defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<DF>))
single(DF) -> single<ignoreVF, abortEF, DF>; single(DF) -> single<ignoreVF, abortEF, DF>;
PUSHMI_TEMPLATE(class VF, class EF) PUSHMI_TEMPLATE(class VF, class EF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not defer::Receiver<VF> && not defer::Invocable<EF&>)) (requires defer::True<> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<VF> && not defer::Invocable<EF&>))
single(VF, EF) -> single<VF, EF, ignoreDF>; single(VF, EF) -> single<VF, EF, ignoreDF>;
PUSHMI_TEMPLATE(class EF, class DF) PUSHMI_TEMPLATE(class EF, class DF)
(requires defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<EF>)) (requires defer::True<> && defer::Invocable<DF&> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Receiver<EF>))
single(EF, DF) -> single<ignoreVF, EF, DF>; single(EF, DF) -> single<ignoreVF, EF, DF>;
PUSHMI_TEMPLATE(class VF, class EF, class DF) PUSHMI_TEMPLATE(class VF, class EF, class DF)
...@@ -376,11 +376,11 @@ PUSHMI_TEMPLATE(class VF, class EF, class DF) ...@@ -376,11 +376,11 @@ PUSHMI_TEMPLATE(class VF, class EF, class DF)
single(VF, EF, DF) -> single<VF, EF, DF>; single(VF, EF, DF) -> single<VF, EF, DF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires defer::Receiver<Data, is_single<>>) (requires defer::True<> && defer::Receiver<Data, is_single<>>)
single(Data d) -> single<Data, passDVF, passDEF, passDDF>; single(Data d) -> single<Data, passDVF, passDEF, passDDF>;
PUSHMI_TEMPLATE(class Data, class DVF) PUSHMI_TEMPLATE(class Data, class DVF)
(requires defer::Receiver<Data, is_single<>> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Invocable<DVF&, Data&>)) (requires defer::True<> && defer::Receiver<Data, is_single<>> PUSHMI_BROKEN_SUBSUMPTION(&& not defer::Invocable<DVF&, Data&>))
single(Data d, DVF vf) -> single<Data, DVF, passDEF, passDDF>; single(Data d, DVF vf) -> single<Data, DVF, passDEF, passDDF>;
PUSHMI_TEMPLATE(class Data, class... DEFN) PUSHMI_TEMPLATE(class Data, class... DEFN)
...@@ -389,7 +389,7 @@ single(Data d, on_error_fn<DEFN...>) -> ...@@ -389,7 +389,7 @@ single(Data d, on_error_fn<DEFN...>) ->
single<Data, passDVF, on_error_fn<DEFN...>, passDDF>; single<Data, passDVF, on_error_fn<DEFN...>, passDDF>;
PUSHMI_TEMPLATE(class Data, class DDF) PUSHMI_TEMPLATE(class Data, class DDF)
(requires defer::Receiver<Data, is_single<>> && defer::Invocable<DDF&, Data&>) (requires defer::True<> && defer::Receiver<Data, is_single<>> && defer::Invocable<DDF&, Data&>)
single(Data d, DDF) -> single<Data, passDVF, passDEF, DDF>; single(Data d, DDF) -> single<Data, passDVF, passDEF, DDF>;
PUSHMI_TEMPLATE(class Data, class DVF, class DEF) PUSHMI_TEMPLATE(class Data, class DVF, class DEF)
......
...@@ -157,12 +157,12 @@ inline auto make_single_deferred() -> single_deferred<ignoreSF> { ...@@ -157,12 +157,12 @@ inline auto make_single_deferred() -> single_deferred<ignoreSF> {
return {}; return {};
} }
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
auto make_single_deferred(SF sf) -> single_deferred<SF> { auto make_single_deferred(SF sf) -> single_deferred<SF> {
return single_deferred<SF>{std::move(sf)}; return single_deferred<SF>{std::move(sf)};
} }
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires Sender<Data, is_single<>>) (requires True<> && Sender<Data, is_single<>>)
auto make_single_deferred(Data d) -> single_deferred<Data, passDSF> { auto make_single_deferred(Data d) -> single_deferred<Data, passDSF> {
return single_deferred<Data, passDSF>{std::move(d)}; return single_deferred<Data, passDSF>{std::move(d)};
} }
...@@ -178,11 +178,11 @@ auto make_single_deferred(Data d, DSF sf) -> single_deferred<Data, DSF> { ...@@ -178,11 +178,11 @@ auto make_single_deferred(Data d, DSF sf) -> single_deferred<Data, DSF> {
single_deferred() -> single_deferred<ignoreSF>; single_deferred() -> single_deferred<ignoreSF>;
PUSHMI_TEMPLATE(class SF) PUSHMI_TEMPLATE(class SF)
(requires PUSHMI_BROKEN_SUBSUMPTION(not Sender<SF>)) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender<SF>))
single_deferred(SF) -> single_deferred<SF>; single_deferred(SF) -> single_deferred<SF>;
PUSHMI_TEMPLATE(class Data) PUSHMI_TEMPLATE(class Data)
(requires Sender<Data, is_single<>>) (requires True<> && Sender<Data, is_single<>>)
single_deferred(Data) -> single_deferred<Data, passDSF>; single_deferred(Data) -> single_deferred<Data, passDSF>;
PUSHMI_TEMPLATE(class Data, class DSF) PUSHMI_TEMPLATE(class Data, class DSF)
......
...@@ -56,12 +56,16 @@ using void_t = void; ...@@ -56,12 +56,16 @@ using void_t = void;
template <class T> template <class T>
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>; using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
PUSHMI_CONCEPT_DEF(
template(class... Args)
(concept True)(Args...),
true
);
PUSHMI_CONCEPT_DEF( PUSHMI_CONCEPT_DEF(
template(class T, template<class...> class C, class... Args) template(class T, template<class...> class C, class... Args)
(concept Valid)(T, C, Args...), (concept Valid)(T, C, Args...),
requires () ( True< C<T, Args...> >
typename_<C<T, Args...>>
)
); );
PUSHMI_CONCEPT_DEF( 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