#include <iostream>
#include <functional>
#include <vector>
struct A
{
void do_some_thing( long arg ) const
{ std::cout << "A::do_something(" << arg << ")\n" ; }
};
struct B
{
int do_some_thing_else( int v )
{
std::cout << "B::do_something_else(" << v << ")\n" ;
return i += v ;
}
int i = 0 ;
};
void do_a_third_thing( int v ) { std::cout << "::do_a_third_thing(" << v << ")\n" ; }
struct to_do_list
{
template < typename FN, typename... ARGS > void add( FN fn, ARGS&&... args )
{ things_to_be_done.emplace_back( std::bind( fn, std::forward<ARGS>(args)..., std::placeholders::_1 ) ) ; }
void do_them_now( int with_this_arg )
{
int cnt = 0 ;
for( const auto& fn : things_to_be_done )
{
std::cout << ++cnt << ". " ;
fn(with_this_arg) ;