mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
more work
This commit is contained in:
parent
1131215890
commit
88a56b4d3f
@ -19,16 +19,6 @@
|
||||
#ifndef _CALLBACK_H_
|
||||
#define _CALLBACK_H_
|
||||
|
||||
enum SpellCastResult
|
||||
{
|
||||
SPELL_FAILED_SUCCESS = 0,
|
||||
SPELL_FAILED_AFFECTING_COMBAT = 1,
|
||||
SPELL_FAILED_ALREADY_AT_FULL_HEALTH = 2,
|
||||
SPELL_FAILED_ALREADY_AT_FULL_MANA = 3,
|
||||
SPELL_FAILED_ALREADY_AT_FULL_POWER = 4,
|
||||
SPELL_FAILED_ALREADY_BEING_TAMED = 5
|
||||
};
|
||||
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
||||
@ -54,6 +54,9 @@ namespace detail
|
||||
template <typename _CTy, typename... _ATy>
|
||||
struct unary_chainer_t;
|
||||
|
||||
template <typename...>
|
||||
struct multiple_when_all_chainer_t;
|
||||
|
||||
/// Functional traits forward declaration.
|
||||
template <typename... _ATy>
|
||||
struct functional_traits;
|
||||
@ -176,39 +179,18 @@ public:
|
||||
}, std::move(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
template<typename... _CTy>
|
||||
Continuable& _wrap_all(_CTy&&...)
|
||||
{
|
||||
typedef detail::multiple_all_chainer<_CTy...> type;
|
||||
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
/// Placeholder
|
||||
template<typename... _CTy>
|
||||
auto all(_CTy&&... functionals)
|
||||
-> Continuable<SpellCastResult, SpellCastResult>
|
||||
/*typename detail::multiple_when_all_chainer_t<
|
||||
-> typename detail::multiple_when_all_chainer_t<
|
||||
fu::identity<_ATy...>,
|
||||
fu::identity<_CTy...>
|
||||
>::make_result::continuable_t
|
||||
*/
|
||||
{
|
||||
return then([]()
|
||||
{
|
||||
return Continuable<SpellCastResult, SpellCastResult>();
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
return then(
|
||||
detail::multiple_when_all_chainer_t<
|
||||
fu::identity<_ATy...>,
|
||||
fu::identity<_CTy...>
|
||||
>::make_when_all(std::forward<_CTy>(functionals)...))
|
||||
*/
|
||||
>::make_when_all(std::forward<_CTy>(functionals)...));
|
||||
}
|
||||
|
||||
/// Placeholder
|
||||
@ -315,10 +297,6 @@ namespace detail
|
||||
typedef fu::argument_type_of_t<callback_t> callback_arguments_t;
|
||||
};
|
||||
|
||||
/// Helper trait for multiple chains like `Continuable::all`
|
||||
template <typename...>
|
||||
struct multiple_when_all_chainer_t;
|
||||
|
||||
template<typename Left, typename Right>
|
||||
struct concat_identities;
|
||||
|
||||
@ -518,12 +496,13 @@ namespace detail
|
||||
return [=](_ATy&&... args)
|
||||
{
|
||||
|
||||
|
||||
// Fake continuable
|
||||
return continuable_t();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/// Helper trait for multiple chains like `Continuable::all`
|
||||
template <typename... _ATy, typename... _CTy>
|
||||
struct multiple_when_all_chainer_t<fu::identity<_ATy...>, fu::identity<_CTy...>>
|
||||
{
|
||||
|
||||
10
test.cpp
10
test.cpp
@ -12,7 +12,15 @@
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
|
||||
enum SpellCastResult
|
||||
{
|
||||
SPELL_FAILED_SUCCESS = 0,
|
||||
SPELL_FAILED_AFFECTING_COMBAT = 1,
|
||||
SPELL_FAILED_ALREADY_AT_FULL_HEALTH = 2,
|
||||
SPELL_FAILED_ALREADY_AT_FULL_MANA = 3,
|
||||
SPELL_FAILED_ALREADY_AT_FULL_POWER = 4,
|
||||
SPELL_FAILED_ALREADY_BEING_TAMED = 5
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using Optional = boost::optional<T>;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user