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