mirror of
https://github.com/Naios/continuable.git
synced 2026-02-13 21:59:48 +08:00
more work
This commit is contained in:
parent
71ef5ed2ef
commit
facb6c852d
@ -18,6 +18,27 @@
|
|||||||
#ifndef _CONTINUABLE_H_
|
#ifndef _CONTINUABLE_H_
|
||||||
#define _CONTINUABLE_H_
|
#define _CONTINUABLE_H_
|
||||||
|
|
||||||
|
#include "Callback.h"
|
||||||
|
|
||||||
|
template <typename _MTy>
|
||||||
|
class ContinuableBase
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename _ATy, typename _WTy = void>
|
||||||
|
class Continuable;
|
||||||
|
|
||||||
|
template <typename... _ATy>
|
||||||
|
class Continuable<Callback<_ATy...>, void>
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename... _ATy, typename _WTy>
|
||||||
|
class Continuable<Callback<_ATy...>, _WTy>
|
||||||
|
{
|
||||||
|
static_assert(false, "");
|
||||||
|
};
|
||||||
|
|
||||||
#endif /// _CONTINUABLE_H_
|
#endif /// _CONTINUABLE_H_
|
||||||
|
|||||||
@ -63,23 +63,23 @@ fluent_step make_waterfall()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Continueable
|
struct ProtoContinueable
|
||||||
{
|
{
|
||||||
template <typename Callback>
|
template <typename Callback>
|
||||||
Continueable then(Callback&& callback)
|
ProtoContinueable then(Callback&& callback)
|
||||||
{
|
{
|
||||||
return Continueable();
|
return ProtoContinueable();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
Continueable weak(Container& container)
|
ProtoContinueable weak(Container& container)
|
||||||
{
|
{
|
||||||
return Continueable();
|
return ProtoContinueable();
|
||||||
}
|
}
|
||||||
|
|
||||||
Continueable strong()
|
ProtoContinueable strong()
|
||||||
{
|
{
|
||||||
return Continueable();
|
return ProtoContinueable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
12
test.cpp
12
test.cpp
@ -3,24 +3,25 @@
|
|||||||
|
|
||||||
#include "Callback.h"
|
#include "Callback.h"
|
||||||
#include "WeakCallbackContainer.h"
|
#include "WeakCallbackContainer.h"
|
||||||
|
#include "Continuable.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
Continueable CastSpell(int id)
|
ProtoContinueable CastSpell(int id)
|
||||||
{
|
{
|
||||||
std::cout << "Cast " << id << std::endl;
|
std::cout << "Cast " << id << std::endl;
|
||||||
|
|
||||||
// on success call true
|
// on success call true
|
||||||
return Continueable();
|
return ProtoContinueable();
|
||||||
}
|
}
|
||||||
|
|
||||||
Continueable MoveTo(int point)
|
ProtoContinueable MoveTo(int point)
|
||||||
{
|
{
|
||||||
std::cout << "Move to point " << point << std::endl;
|
std::cout << "Move to point " << point << std::endl;
|
||||||
|
|
||||||
// on success call true
|
// on success call true
|
||||||
return Continueable();
|
return ProtoContinueable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastSpell(int id, Callback<bool> const& callback)
|
void CastSpell(int id, Callback<bool> const& callback)
|
||||||
@ -146,5 +147,8 @@ int main(int argc, char** argv)
|
|||||||
wrapped();
|
wrapped();
|
||||||
wrapped2();
|
wrapped2();
|
||||||
|
|
||||||
|
|
||||||
|
typedef Continuable<Callback<bool>> cont;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user