Ticket #8102: std-tuple-get.patch

File std-tuple-get.patch, 3.0 KB (added by Eric Niebler, 10 years ago)

replace std::get with boost::get when <tuple> is not available.

  • boost/signals2/detail/variadic_slot_invoker.hpp

     
    1515#ifndef BOOST_SIGNALS2_DETAIL_VARIADIC_SLOT_INVOKER_HPP
    1616#define BOOST_SIGNALS2_DETAIL_VARIADIC_SLOT_INVOKER_HPP
    1717
     18#include <boost/mpl/size_t.hpp>
    1819#include <boost/signals2/detail/variadic_arg_type.hpp>
    1920
    2021// if compiler has std::tuple use it instead of boost::tuple
     
    2223#ifdef BOOST_NO_CXX11_HDR_TUPLE
    2324#include <boost/tuple/tuple.hpp>
    2425#define BOOST_SIGNALS2_TUPLE boost::tuple
     26#define BOOST_SIGNALS2_GET boost::get
    2527#else
    2628#include <tuple>
    2729#define BOOST_SIGNALS2_TUPLE std::tuple
     30#define BOOST_SIGNALS2_GET std::get
    2831#endif
    2932
    3033namespace boost
     
    7073      public:
    7174        typedef R result_type;
    7275
    73         template<typename Func, typename ... Args>
    74           R operator()(Func &func, BOOST_SIGNALS2_TUPLE<Args...> args) const
     76        template<typename Func, typename ... Args, std::size_t N>
     77        R operator()(Func &func, BOOST_SIGNALS2_TUPLE<Args...> args, mpl::size_t<N>) const
    7578        {
    76           typedef typename make_unsigned_meta_array<sizeof...(Args)>::type indices_type;
     79          typedef typename make_unsigned_meta_array<N>::type indices_type;
    7780          typename Func::result_type *resolver = 0;
    7881          return m_invoke(resolver, func, indices_type(), args);
    7982        }
     
    8184        template<typename T, typename Func, unsigned ... indices, typename ... Args>
    8285          R m_invoke(T *, Func &func, unsigned_meta_array<indices...>, BOOST_SIGNALS2_TUPLE<Args...> args) const
    8386        {
    84           return func(std::get<indices>(args)...);
     87          return func(BOOST_SIGNALS2_GET<indices>(args)...);
    8588        }
    8689        template<typename Func, unsigned ... indices, typename ... Args>
    8790          R m_invoke(void *, Func &func, unsigned_meta_array<indices...>, BOOST_SIGNALS2_TUPLE<Args...> args) const
    8891        {
    89           func(std::get<indices>(args)...);
     92          func(BOOST_SIGNALS2_GET<indices>(args)...);
    9093          return R();
    9194        }
    9295      };
     
    111114        result_type m_invoke(const ConnectionBodyType &connectionBody,
    112115          const void_type *) const
    113116        {
    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)>());
    115118          return void_type();
    116119        }
    117120        template<typename ConnectionBodyType>
    118121          result_type m_invoke(const ConnectionBodyType &connectionBody, ...) const
    119122        {
    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)>());
    121124        }
    122125        BOOST_SIGNALS2_TUPLE<Args& ...> _args;
    123126      };