#include struct Fib { int fn = 1, fn1 = 0; void * next = nullptr; int operator()() { if ( __builtin_expect(next != 0, 1) ) goto *next; next = &&s1; for ( ;; ) { return fn1; s1: ; int fn0 = fn + fn1; fn1 = fn; fn = fn0; return fn1; } } }; int main() { Fib f1, f2; for ( int i = 0; i < 10; i += 1 ) { printf( "%d %d\n", f1(), f2() ); } } // Local Variables: // // tab-width: 4 // // compile-command: "gcc-8 Fib3.cc" // // End: //