Last active
January 7, 2016 00:03
-
-
Save hbarcelos/1b8820b0320bdf79f727 to your computer and use it in GitHub Desktop.
C++ Promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include <functional> | |
template <typename ValueT, typename ReasonT> | |
class Promise { | |
private: | |
enum State { | |
FULFILLED, REJECTED, PENDING | |
}; | |
State mState; | |
ValueT value; | |
ReasonT reason; | |
void setState(State s); | |
public: | |
Promise(std::function<void(std::function<Promise<ValueT, ReasonT>> resolve,std::function<Promise<ValueT, ReasonT>> reject)>); | |
~Promise(); | |
}; | |
template <typename ValueT, typename ReasonT> | |
Promise::Promise(std::function<void(std::function<Promise<ValueT, ReasonT>> resolve,std::function<Promise<ValueT, ReasonT>> reject)>): | |
mState(Promise::State::PENDING) { | |
} | |
template <typename ValueT, typename ReasonT> | |
Promise::setState(Promise::State s) { | |
mState = s; | |
} | |
int main(int argc, char* argv[]) { | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment