Ticket #8102: std-tuple-get.patch
File std-tuple-get.patch, 3.0 KB (added by , 10 years ago) |
---|
-
boost/signals2/detail/variadic_slot_invoker.hpp
15 15 #ifndef BOOST_SIGNALS2_DETAIL_VARIADIC_SLOT_INVOKER_HPP 16 16 #define BOOST_SIGNALS2_DETAIL_VARIADIC_SLOT_INVOKER_HPP 17 17 18 #include <boost/mpl/size_t.hpp> 18 19 #include <boost/signals2/detail/variadic_arg_type.hpp> 19 20 20 21 // if compiler has std::tuple use it instead of boost::tuple … … 22 23 #ifdef BOOST_NO_CXX11_HDR_TUPLE 23 24 #include <boost/tuple/tuple.hpp> 24 25 #define BOOST_SIGNALS2_TUPLE boost::tuple 26 #define BOOST_SIGNALS2_GET boost::get 25 27 #else 26 28 #include <tuple> 27 29 #define BOOST_SIGNALS2_TUPLE std::tuple 30 #define BOOST_SIGNALS2_GET std::get 28 31 #endif 29 32 30 33 namespace boost … … 70 73 public: 71 74 typedef R result_type; 72 75 73 template<typename Func, typename ... Args >74 R operator()(Func &func, BOOST_SIGNALS2_TUPLE<Args...> args) const76 template<typename Func, typename ... Args, std::size_t N> 77 R operator()(Func &func, BOOST_SIGNALS2_TUPLE<Args...> args, mpl::size_t<N>) const 75 78 { 76 typedef typename make_unsigned_meta_array< sizeof...(Args)>::type indices_type;79 typedef typename make_unsigned_meta_array<N>::type indices_type; 77 80 typename Func::result_type *resolver = 0; 78 81 return m_invoke(resolver, func, indices_type(), args); 79 82 } … … 81 84 template<typename T, typename Func, unsigned ... indices, typename ... Args> 82 85 R m_invoke(T *, Func &func, unsigned_meta_array<indices...>, BOOST_SIGNALS2_TUPLE<Args...> args) const 83 86 { 84 return func( std::get<indices>(args)...);87 return func(BOOST_SIGNALS2_GET<indices>(args)...); 85 88 } 86 89 template<typename Func, unsigned ... indices, typename ... Args> 87 90 R m_invoke(void *, Func &func, unsigned_meta_array<indices...>, BOOST_SIGNALS2_TUPLE<Args...> args) const 88 91 { 89 func( std::get<indices>(args)...);92 func(BOOST_SIGNALS2_GET<indices>(args)...); 90 93 return R(); 91 94 } 92 95 }; … … 111 114 result_type m_invoke(const ConnectionBodyType &connectionBody, 112 115 const void_type *) const 113 116 { 114 return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args );117 return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args, mpl::size_t<sizeof...(Args)>()); 115 118 return void_type(); 116 119 } 117 120 template<typename ConnectionBodyType> 118 121 result_type m_invoke(const ConnectionBodyType &connectionBody, ...) const 119 122 { 120 return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args );123 return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args, mpl::size_t<sizeof...(Args)>()); 121 124 } 122 125 BOOST_SIGNALS2_TUPLE<Args& ...> _args; 123 126 };