1 2 // Copyright Oliver Kowalke 2014. 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 #ifndef BOOST_CONTEXT_DETAIL_INVOKE_H 8 #define BOOST_CONTEXT_DETAIL_INVOKE_H 9 10 #include <functional> 11 #include <type_traits> 12 #include <utility> 13 14 #include <boost/config.hpp> 15 16 #include <boost/context/detail/config.hpp> 17 18 #ifdef BOOST_HAS_ABI_HEADERS 19 # include BOOST_ABI_PREFIX 20 #endif 21 22 namespace boost { 23 namespace context { 24 namespace detail { 25 26 template< typename Fn, typename ... Args > 27 typename std::enable_if< 28 std::is_member_pointer< typename std::decay< Fn >::type >::value, 29 typename std::result_of< Fn &&( Args && ... ) >::type 30 >::type invoke(Fn && fn,Args &&...args)31invoke( Fn && fn, Args && ... args) { 32 return std::mem_fn( fn)( std::forward< Args >( args) ... ); 33 } 34 35 template< typename Fn, typename ... Args > 36 typename std::enable_if< 37 ! std::is_member_pointer< typename std::decay< Fn >::type >::value, 38 typename std::result_of< Fn &&( Args && ... ) >::type 39 >::type invoke(Fn && fn,Args &&...args)40invoke( Fn && fn, Args && ... args) { 41 return std::forward< Fn >( fn)( std::forward< Args >( args) ... ); 42 } 43 44 }}} 45 46 #ifdef BOOST_HAS_ABI_HEADERS 47 #include BOOST_ABI_SUFFIX 48 #endif 49 50 #endif // BOOST_CONTEXT_DETAIL_INVOKE_H 51