Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void foo( const int i )
- {
- std::cout << ( i + i ) << std::endl;
- }
- int bar( const double d )
- {
- const int ret = static_cast< int >( d + 0.7 );
- std::cout << ( ret ) << std::endl;
- return ret;
- }
- template< class Ret,
- class Callable,
- class ...Args >
- Ret callAnyProducer( Callable callable, Args&&... args )
- {
- // auto start = current_time_point();
- Ret ret = callable( std::forward( args... ) );
- // auto duration = start - current_time_point()
- return ret;
- }
- int main()
- {
- //getExecutionTime( foo, 1 );
- auto a = getExecutionTime( bar, 3.2 );
- return 0;
- }
- template< class Callable,
- class ...Args >
- auto getExecutionTime( Callable callable, Args&&... args )
- {
- //auto start = current_time_point();
- auto ret = callable( std::forward<Args...>( (args,...) ) );
- //auto duration = start - current_time_point()
- return ret;
- }
- int main()
- {
- //auto a = getExecutionTime( foo, 1 );
- auto a = getExecutionTime( bar, 3.2 );
- return 0;
- }
Add Comment
Please, Sign In to add comment