/* This output was obtained with gcc 4.7.0 -std=c++11 and with Xcode 4.4.1, Mac OS 10.8.1, LLVM Compiler 4.0 -std=c++11 libc++ */ demo of bind with read-only integer variables and constants 10+20+30=60 result is 60 1+2+3=6 result is 6 100+200+300=600 result is 600 1+2+3=6 result is 6 1 2 3 6+2+3=11 1+11+3=15 result from nested bind is 15 demo of bind with function that modifies parameters 1 2 3 mod23 input: 1 2 3 mod23 output: 1 3 6 1 2 3 mod23 input: 1 2 3 mod23 output: 1 3 6 1 2 6 mod23 input: 1 2 6 mod23 output: 1 3 9 1 3 9 mod23 input: 1 3 9 mod23 output: 1 4 13 1 4 13 mod23 input: 10 20 30 mod23 output: 10 30 60 demo of bind with ref bound argument to hand in cout argument 1 demo of bind with cout call argument 1 demo of bind with cout and int literal call argument 6 demo with rvalues for call argument 4 1 2 mod23 input: 3 4 13 mod23 output: 3 7 20 demo with rvalues for bound argument 4 4 demo of bind with modifying single-parameter function i modified to 47 int1 is now 42 i modified to 47 int1 is now 47 i modified to 81 int2 is now 81 i modified to 17 Using a single Thing object Output from print const member functions before and after applying update and set_value modifying member functions Thing 1 Thing 1 Thing updated to 2 Thing 1 Thing updated to 2 Thing 2 Thing updated to 3 Thing 3 Thing value set to 42 Thing 42 Thing value set to 76 Thing 76 Thing value set to 42 Thing 42 with arg 76 Thing 42 with args 88 76 Thing42 written to stream Thing 42 Thing 42 Thing 42 print_int_Thing 88 Thing: 42 Thing 42 Thing 42 Thing 42 print_int_Thing 88 Thing: 42 Thing updated to 43 Thing updated to 43 Thing updated to 44 Thing value set to 76 Thing value set to 76 Thing value set to 76 Using a single pointer to Thing Output from print const member functions before and after applying update and set_value modifying member functions Thing 1 Thing updated to 2 Thing value set to 42 Thing 42 Thing value set to 76 Thing 76 Thing value set to 42 Thing 42 with arg 76 Thing 42 with args 88 76 1+5+9=15 2+5+9=16 3+5+9=17 1 2 3 mod23 input: 1 2 1 mod23 output: 1 3 4 mod23 input: 1 3 2 mod23 output: 1 4 6 mod23 input: 1 4 3 mod23 output: 1 5 8 4 6 8 Using bind on list to call write_int with cout argument 4 6 8 Thing 1 Thing 2 Thing 3 print_Thing_int_int Thing: 1 42 76 print_Thing_int_int Thing: 2 42 76 print_Thing_int_int Thing: 3 42 76 Thing updated to 2 Thing updated to 3 Thing updated to 4 Thing value set to 42 Thing value set to 42 Thing value set to 42 Thing 1 Using list container Using bind on obj_list to call Thing::print Thing 42 Thing 42 Thing 42 Using bind on obj_list to call Thing::print2arg Thing 42 with args 42 76 Thing 42 with args 42 76 Thing 42 with args 42 76 Using bind on obj_list to call Thing::write with cout argument Thing42 written to stream Thing42 written to stream Thing42 written to stream Using mem_fn on obj_list to call Thing::print and update Thing 42 Thing 42 Thing 42 Thing updated to 43 Thing updated to 43 Thing updated to 43 Thing 43 Thing 43 Thing 43 Using bind on obj_list to call Thing::print and update Thing 43 Thing 43 Thing 43 Thing updated to 44 Thing updated to 44 Thing updated to 44 Thing 44 Thing 44 Thing 44 Using bind on obj_list to call Thing::print and Thing::set_value Thing 44 Thing 44 Thing 44 Thing value set to 42 Thing value set to 42 Thing value set to 42 Thing 42 Thing 42 Thing 42 Using list container Using bind on ptr_list for print Thing 1 Thing 2 Thing 3 Using bind on ptr_list to call Thing::print2arg Thing 1 with args 42 76 Thing 2 with args 42 76 Thing 3 with args 42 76 Using bind on ptr_list to call Thing::update Thing updated to 2 Thing updated to 3 Thing updated to 4 Using bind on ptr_list for set_value Thing 2 Thing 3 Thing 4 Thing value set to 42 Thing value set to 42 Thing value set to 42 Thing 42 Thing 42 Thing 42 Using bind on ptr_list to call Thing::write with cout argument Thing42 written to stream Thing42 written to stream Thing42 written to stream Using map container Output from using bind of print to bind of second Thing 1 Thing 2 Thing 3 Output from using bind of print1arg and print2arg to bind of second Thing 1 with arg 42 Thing 2 with arg 42 Thing 3 with arg 42 Output from using bind of non-modifying ordinary function to bind of second Thing 1 Thing 2 Thing 3 Thing 1 Thing 2 Thing 3 Output from using bind of modifying member function to bind of second Thing updated to 2 Thing updated to 3 Thing updated to 4 Thing 2 Thing 3 Thing 4 Output from using bind of modifying ordinary function to bind of second Thing updated to 3 Thing updated to 4 Thing updated to 5 Thing 3 Thing 4 Thing 5 Output from using bind of Thing::write to bind of second with cout argument Thing3 written to stream Thing4 written to stream Thing5 written to stream Using map container Output from print const member functions before and after applying update and set_value modifying member functions Thing 1 Thing 2 Thing 3 Thing 1 with arg 42 Thing 2 with arg 42 Thing 3 with arg 42 Thing 1 with args 42 76 Thing 2 with args 42 76 Thing 3 with args 42 76 Thing updated to 2 Thing updated to 3 Thing updated to 4 Thing 2 Thing 3 Thing 4 Thing value set to 42 Thing value set to 42 Thing value set to 42 Thing 42 Thing 42 Thing 42 Thing 42 Thing 42 Thing 42 Thing 42 Thing 42 Thing 42 print_Thing_ptr_int Thing: 42 42 76 print_Thing_ptr_int Thing: 42 42 76 print_Thing_ptr_int Thing: 42 42 76 Thing 42 Thing 42 Thing 42 Output from using bind of Thing::write to bind of second with cout argument Thing42 written to stream Thing42 written to stream Thing42 written to stream done!