48 #include <type_traits>  
  110 template<
class T, 
bool unref>
 
  136 #if defined(DOXYGEN_PARSING) || defined(CGU_USE_TUPLE) 
  138 #ifndef DOXYGEN_PARSING 
  140 namespace TupleHelper {
 
  173 template<std::size_t... indices>
 
  175   typedef IndexList<indices...> Type;
 
  178 template<std::size_t count, std::size_t... indices>
 
  179 struct MakeIndexList: 
public MakeIndexList<count - 1, count - 1, indices...> {};
 
  183 template<std::size_t... indices>
 
  184 struct MakeIndexList<0, indices...>: 
public IndexList<indices...> {};
 
  186 template <
class Obj, 
class Ret, 
class... FuncArgs, 
class Tuple,
 
  187       std::size_t... indices, 
class... OtherArgs>
 
  188 Ret tuple_apply_impl(Obj& obj,
 
  189              Ret (Obj::* func) (FuncArgs...),
 
  191              IndexList<indices...>,
 
  192              OtherArgs&&... args) {
 
  193   return (obj.*func)(std::get<indices>(std::forward<Tuple>(t))..., std::forward<OtherArgs>(args)...);
 
  196 template <
class Obj, 
class Ret, 
class... FuncArgs, 
class Tuple,
 
  197       std::size_t... indices, 
class... OtherArgs>
 
  198 Ret tuple_apply_impl(
const Obj& obj,
 
  199              Ret (Obj::* func) (FuncArgs...) 
const,
 
  201              IndexList<indices...>,
 
  202              OtherArgs&&... args) {
 
  203   return (obj.*func)(std::get<indices>(std::forward<Tuple>(t))..., std::forward<OtherArgs>(args)...);
 
  206 template <
class Ret, 
class Func, 
class Tuple,
 
  207       std::size_t... indices, 
class... OtherArgs>
 
  208 Ret tuple_apply_impl(Func&& func,
 
  210              IndexList<indices...>,
 
  211              OtherArgs&&... args) {
 
  212   return func(std::get<indices>(std::forward<Tuple>(t))..., std::forward<OtherArgs>(args)...);
 
  217 #endif // DOXYGEN_PARSING 
  305          const std::tuple<TupleArgs...>& t,
 
  306          OtherArgs&&... args) -> 
typename std::result_of<Func(
const TupleArgs&..., OtherArgs&&...)>::type {
 
  307   typedef typename std::result_of<Func(
const TupleArgs&..., OtherArgs&&...)>::type Ret;
 
  308   typedef typename TupleHelper::MakeIndexList<
sizeof...(TupleArgs)>::Type List;
 
  309   return TupleHelper::tuple_apply_impl<Ret>(std::forward<Func>(func),
 
  312                         std::forward<OtherArgs>(args)...);
 
  341          std::tuple<TupleArgs...>& t,
 
  342          OtherArgs&&... args) -> 
typename std::result_of<Func(TupleArgs&..., OtherArgs&&...)>::type {
 
  343   typedef typename std::result_of<Func(TupleArgs&..., OtherArgs&&...)>::type Ret;
 
  344   typedef typename TupleHelper::MakeIndexList<
sizeof...(TupleArgs)>::Type List;
 
  345   return TupleHelper::tuple_apply_impl<Ret>(std::forward<Func>(func),
 
  348                         std::forward<OtherArgs>(args)...);
 
  377          std::tuple<TupleArgs...>&& t,
 
  378          OtherArgs&&... args) -> 
typename std::result_of<Func(TupleArgs&&..., OtherArgs&&...)>::type {
 
  379   typedef typename std::result_of<Func(TupleArgs&&..., OtherArgs&&...)>::type Ret;
 
  380   typedef typename TupleHelper::MakeIndexList<
sizeof...(TupleArgs)>::Type List;
 
  381   return TupleHelper::tuple_apply_impl<Ret>(std::forward<Func>(func),
 
  384                         std::forward<OtherArgs>(args)...);
 
  408 template<
class Obj, 
class Ret, 
class... FuncArgs, 
class Tuple, 
class... OtherArgs>
 
  410         Ret (Obj::* func) (FuncArgs...),
 
  412         OtherArgs&&... args) {
 
  413   typedef typename std::remove_reference<Tuple>::type TupleType;
 
  414   static_assert(
sizeof...(FuncArgs) == std::tuple_size<TupleType>::value + 
sizeof...(OtherArgs),
 
  415         "The arity of the function passed to tuple_apply() and the " 
  416         "arguments passed to it do not match");
 
  417   typedef typename TupleHelper::MakeIndexList<std::tuple_size<TupleType>::value>::Type List;
 
  418   return TupleHelper::tuple_apply_impl(obj,
 
  420                        std::forward<Tuple>(t),
 
  422                        std::forward<OtherArgs>(args)...);
 
  446 template<
class Obj, 
class Ret, 
class... FuncArgs, 
class Tuple, 
class... OtherArgs>
 
  448         Ret (Obj::* func) (FuncArgs...) 
const,
 
  450         OtherArgs&&... args) {
 
  451   typedef typename std::remove_reference<Tuple>::type TupleType;
 
  452   static_assert(
sizeof...(FuncArgs) == std::tuple_size<TupleType>::value + 
sizeof...(OtherArgs),
 
  453         "The arity of the function passed to tuple_apply() and the " 
  454         "arguments passed to it do not match");
 
  455   typedef typename TupleHelper::MakeIndexList<std::tuple_size<TupleType>::value>::Type List;
 
  456   return TupleHelper::tuple_apply_impl(obj,
 
  458                        std::forward<Tuple>(t),
 
  460                        std::forward<OtherArgs>(args)...);
 
  463 #endif // CGU_USE_TUPLE 
  467 #endif // CGU_PARAM_H