#include #include #include #include "either.hxx" using std::cout; using std::endl; using std::string; using std::function; int main() { function(int)> f = [] (int x) { if (x == 2) { return either::left("Cannot deal with 2."); } if (x == 12) { return either::left("Cannot deal with 12."); } return either::right(x*2); }; cout << (((Return(3) >>= f) >>= f) >>= f) << endl; // -> cout << (((Return(4) >>= f) >>= f) >>= f) << endl; // -> return 0; }