diff options
Diffstat (limited to 'boost/signals2/detail/variadic_slot_invoker.hpp')
-rw-r--r-- | boost/signals2/detail/variadic_slot_invoker.hpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/boost/signals2/detail/variadic_slot_invoker.hpp b/boost/signals2/detail/variadic_slot_invoker.hpp index b7659a5668..cab331eb1c 100644 --- a/boost/signals2/detail/variadic_slot_invoker.hpp +++ b/boost/signals2/detail/variadic_slot_invoker.hpp @@ -15,16 +15,19 @@ #ifndef BOOST_SIGNALS2_DETAIL_VARIADIC_SLOT_INVOKER_HPP #define BOOST_SIGNALS2_DETAIL_VARIADIC_SLOT_INVOKER_HPP +#include <boost/mpl/size_t.hpp> #include <boost/signals2/detail/variadic_arg_type.hpp> // if compiler has std::tuple use it instead of boost::tuple // because boost::tuple does not have variadic template support at present. #ifdef BOOST_NO_CXX11_HDR_TUPLE -#include <boost/tuple.hpp> +#include <boost/tuple/tuple.hpp> #define BOOST_SIGNALS2_TUPLE boost::tuple +#define BOOST_SIGNALS2_GET boost::get #else #include <tuple> #define BOOST_SIGNALS2_TUPLE std::tuple +#define BOOST_SIGNALS2_GET std::get #endif namespace boost @@ -70,10 +73,10 @@ namespace boost public: typedef R result_type; - template<typename Func, typename ... Args> - R operator()(Func &func, BOOST_SIGNALS2_TUPLE<Args...> args) const + template<typename Func, typename ... Args, std::size_t N> + R operator()(Func &func, BOOST_SIGNALS2_TUPLE<Args...> args, mpl::size_t<N>) const { - typedef typename make_unsigned_meta_array<sizeof...(Args)>::type indices_type; + typedef typename make_unsigned_meta_array<N>::type indices_type; typename Func::result_type *resolver = 0; return m_invoke(resolver, func, indices_type(), args); } @@ -81,12 +84,22 @@ namespace boost template<typename T, typename Func, unsigned ... indices, typename ... Args> R m_invoke(T *, Func &func, unsigned_meta_array<indices...>, BOOST_SIGNALS2_TUPLE<Args...> args) const { - return func(std::get<indices>(args)...); + return func(BOOST_SIGNALS2_GET<indices>(args)...); } template<typename Func, unsigned ... indices, typename ... Args> R m_invoke(void *, Func &func, unsigned_meta_array<indices...>, BOOST_SIGNALS2_TUPLE<Args...> args) const { - func(std::get<indices>(args)...); + func(BOOST_SIGNALS2_GET<indices>(args)...); + return R(); + } + // This overload is redundant, as it is the same as the previous variadic method when + // it has zero "indices" or "Args" variadic template parameters. This overload + // only exists to quiet some unused parameter warnings + // on certain compilers (some versions of gcc and msvc) + template<typename Func> + R m_invoke(void *, Func &func, unsigned_meta_array<>, BOOST_SIGNALS2_TUPLE<>) const + { + func(); return R(); } }; @@ -111,13 +124,12 @@ namespace boost result_type m_invoke(const ConnectionBodyType &connectionBody, const void_type *) const { - return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args); - return void_type(); + return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args, mpl::size_t<sizeof...(Args)>()); } template<typename ConnectionBodyType> result_type m_invoke(const ConnectionBodyType &connectionBody, ...) const { - return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args); + return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args, mpl::size_t<sizeof...(Args)>()); } BOOST_SIGNALS2_TUPLE<Args& ...> _args; }; @@ -125,5 +137,4 @@ namespace boost } // namespace signals2 } // namespace boost - #endif // BOOST_SIGNALS2_DETAIL_VARIADIC_SLOT_INVOKER_HPP |