Created
March 9, 2009 23:16
-
-
Save benjamn/76549 to your computer and use it in GitHub Desktop.
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
template <typename Callable, typename ResultPtr> | |
class nsRunnableFunctor | |
: public nsARunnableFunctor | |
{ | |
Callable mCallable; | |
ResultPtr mResultPtr; | |
public: | |
nsRunnableFunctor(Callable callable, ResultPtr resultPtr) | |
: mCallable(callable) | |
, mResultPtr(resultPtr) | |
{} | |
nsresult Run() | |
{ | |
// This line enforces everything that matters about ResultPtr and Callable: | |
// that mResultPtr can be dereferenced, that mCallable is callable with no | |
// arguments, that the result of this call is non-void, and that the | |
// result can be copied into the L-value resulting from the expression | |
// *mResultPtr. No other properties of the template parameters are in any | |
// way constrained, not even implicitly. Do I feel clever? Yes, I do. | |
*mResultPtr = mCallable(); | |
return AfterRun(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment