more work

This commit is contained in:
Naios 2015-06-10 15:38:11 +02:00
parent 71ef5ed2ef
commit facb6c852d
3 changed files with 36 additions and 11 deletions

View File

@ -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_

View File

@ -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();
} }
}; };

View File

@ -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;
} }