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_
|
#ifndef _CALLBACK_H_
|
||||||
#define _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 <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|||||||
@ -54,6 +54,9 @@ namespace detail
|
|||||||
template <typename _CTy, typename... _ATy>
|
template <typename _CTy, typename... _ATy>
|
||||||
struct unary_chainer_t;
|
struct unary_chainer_t;
|
||||||
|
|
||||||
|
template <typename...>
|
||||||
|
struct multiple_when_all_chainer_t;
|
||||||
|
|
||||||
/// Functional traits forward declaration.
|
/// Functional traits forward declaration.
|
||||||
template <typename... _ATy>
|
template <typename... _ATy>
|
||||||
struct functional_traits;
|
struct functional_traits;
|
||||||
@ -176,39 +179,18 @@ public:
|
|||||||
}, std::move(*this));
|
}, std::move(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
template<typename... _CTy>
|
|
||||||
Continuable& _wrap_all(_CTy&&...)
|
|
||||||
{
|
|
||||||
typedef detail::multiple_all_chainer<_CTy...> type;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// Placeholder
|
|
||||||
template<typename... _CTy>
|
template<typename... _CTy>
|
||||||
auto all(_CTy&&... functionals)
|
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<_ATy...>,
|
||||||
fu::identity<_CTy...>
|
fu::identity<_CTy...>
|
||||||
>::make_result::continuable_t
|
>::make_result::continuable_t
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
return then([]()
|
|
||||||
{
|
|
||||||
return Continuable<SpellCastResult, SpellCastResult>();
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
return then(
|
return then(
|
||||||
detail::multiple_when_all_chainer_t<
|
detail::multiple_when_all_chainer_t<
|
||||||
fu::identity<_ATy...>,
|
fu::identity<_ATy...>,
|
||||||
fu::identity<_CTy...>
|
fu::identity<_CTy...>
|
||||||
>::make_when_all(std::forward<_CTy>(functionals)...))
|
>::make_when_all(std::forward<_CTy>(functionals)...));
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Placeholder
|
/// Placeholder
|
||||||
@ -315,10 +297,6 @@ namespace detail
|
|||||||
typedef fu::argument_type_of_t<callback_t> callback_arguments_t;
|
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>
|
template<typename Left, typename Right>
|
||||||
struct concat_identities;
|
struct concat_identities;
|
||||||
|
|
||||||
@ -518,12 +496,13 @@ namespace detail
|
|||||||
return [=](_ATy&&... args)
|
return [=](_ATy&&... args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Fake continuable
|
||||||
return continuable_t();
|
return continuable_t();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Helper trait for multiple chains like `Continuable::all`
|
||||||
template <typename... _ATy, typename... _CTy>
|
template <typename... _ATy, typename... _CTy>
|
||||||
struct multiple_when_all_chainer_t<fu::identity<_ATy...>, fu::identity<_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>
|
#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>
|
template<typename T>
|
||||||
using Optional = boost::optional<T>;
|
using Optional = boost::optional<T>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user