mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
make gcc & clang happy
This commit is contained in:
parent
5a04ef59a1
commit
cc651dae4d
@ -89,7 +89,7 @@ inline shared_callback_of_t<_CTy>
|
||||
{
|
||||
return std::make_shared<callback_of_t<_CTy>>
|
||||
(std::forward<callback_of_t<_CTy>>(callback));
|
||||
}
|
||||
};
|
||||
|
||||
/* Disabled due to clang errors
|
||||
template<typename... Args>
|
||||
|
||||
@ -22,24 +22,20 @@
|
||||
#include "Callback.h"
|
||||
|
||||
template <typename... _ATy>
|
||||
struct Continuable;
|
||||
|
||||
template <typename... _ATy>
|
||||
struct Continuable<Callback<_ATy...>>
|
||||
struct Continuable
|
||||
{
|
||||
typedef std::function<void(Callback<_ATy...>&&)> ForwardFunction;
|
||||
typedef Callback<Callback<_ATy...>&&> ForwardFunction;
|
||||
|
||||
// Function which expects a callback that is inserted from the Continuable
|
||||
// to chain everything together
|
||||
ForwardFunction _callback_insert;
|
||||
|
||||
public:
|
||||
Continuable<Callback<_ATy...>>() { }
|
||||
Continuable<Callback<_ATy...>>(ForwardFunction&& callback_insert)
|
||||
Continuable<_ATy...>() { }
|
||||
Continuable<_ATy...>(ForwardFunction&& callback_insert)
|
||||
: _callback_insert(std::forward<ForwardFunction>(callback_insert)) { }
|
||||
|
||||
template <typename _CTy>
|
||||
Continuable<Callback<_ATy...>>& then(_CTy&&)
|
||||
Continuable<_ATy...>& then(_CTy&&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
@ -54,9 +50,9 @@ namespace detail
|
||||
struct ContinuableFactory<_FTy, _RTy, ::fu::identity<Callback<_ATy...>&&>>
|
||||
{
|
||||
static auto CreateFrom(_FTy&& functional)
|
||||
-> Continuable<Callback<_ATy...>>
|
||||
-> Continuable<_ATy...>
|
||||
{
|
||||
return Continuable<Callback<_ATy...>>(std::forward<_FTy>(functional));
|
||||
return Continuable<_ATy...>(Callback<Callback<_ATy...>&&>(std::forward<_FTy>(functional)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -76,7 +72,7 @@ namespace detail
|
||||
/// });
|
||||
template <typename _FTy>
|
||||
inline auto make_continuable(_FTy&& functional)
|
||||
-> decltype(typename detail::continuable_factory_t<_FTy>::CreateFrom(std::declval<_FTy>()))
|
||||
-> decltype(detail::continuable_factory_t<_FTy>::CreateFrom(std::declval<_FTy>()))
|
||||
{
|
||||
return detail::continuable_factory_t<_FTy>::CreateFrom(std::forward<_FTy>(functional));
|
||||
}
|
||||
|
||||
16
test.cpp
16
test.cpp
@ -16,11 +16,9 @@ enum SpellCastResult
|
||||
SPELL_FAILED_ALREADY_BEING_TAMED = 5
|
||||
};
|
||||
|
||||
// Continuable<Callback<SpellCastResult>>
|
||||
int CastSpell(int id)
|
||||
Continuable<SpellCastResult> CastSpell(int id)
|
||||
{
|
||||
return 1;
|
||||
make_continuable([=](Callback<SpellCastResult>&& callback)
|
||||
return make_continuable([=](Callback<SpellCastResult>&& callback)
|
||||
{
|
||||
std::cout << "Cast " << id << std::endl;
|
||||
|
||||
@ -31,16 +29,14 @@ int CastSpell(int id)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
typedef Continuable<Callback<bool>> cont123;
|
||||
typedef Continuable<bool> cont123;
|
||||
|
||||
// typedef Continuable<Callback<bool>>::type myty1;
|
||||
// typedef Continuable<Callback<bool>, float>::type myty2;
|
||||
|
||||
// Continuable<Callback<SpellCastResult>>
|
||||
CastSpell(63362);
|
||||
|
||||
Continuable<Callback<SpellCastResult>> spell;
|
||||
spell.then([](SpellCastResult result)
|
||||
// Continuable<Callback<SpellCastResult>> spell
|
||||
CastSpell(63362)
|
||||
.then([](SpellCastResult result)
|
||||
{
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user