Created
February 25, 2011 07:26
-
-
Save mrkn/843470 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
int main(int argc, char** argv) { return 0; } | |
#include <iostream> | |
using namespace std; | |
template<class Cond, class Expr> | |
struct While { | |
While(Cond& cond, Expr& expr) | |
{ | |
while (cond()) expr(); | |
} | |
}; | |
struct CountDown { | |
CountDown(long ini) | |
: current_(ini) | |
{} | |
bool operator()() | |
{ | |
return --current_ > 0; | |
} | |
private: | |
long current_; | |
}; | |
struct Hello { | |
void operator()() | |
{ | |
std::cout << "hello world." << std::endl; | |
} | |
}; | |
CountDown ten_times(10); | |
Hello hello; | |
While<CountDown, Hello> w(ten_times, hello); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment