#ifndef _FC_FUNCTION_HPP_ #define _FC_FUNCTION_HPP_ namespace fc { namespace detail { template void call( void* functor ) { (*static_cast(functor*))(); } } class function { public: template function( Functor&& f ) { static_assert( sizeof(f) <= sizeof(store) ); new ((void*)&store[0]) Functor( fc::forward(f) ); call = &detail::call; copy = &detail::copy; move = &detail::move; } function( const function& f ) :call(f.call),move(f.move),copy(f.copy){ copy( &f.store[0], &store[0] ); } function( function&& f ) :call(f.call),move(f.move),copy(f.copy){ move( &f.store[0], &store[0] ); } function& operator = ( function&& f ) { } void operator()()const { call(&store[0]); } private: uint64_t store[8]; void (*call)(void*); void (*move)(void* src, void* dst); void (*copy)(const void*, void* dst); void (*destroy)(void*); }; } #endif // _FC_FUNCTION_HPP_