#pragma once #ifndef FUNC_TRAITS_H_HWIWA6G0 #define FUNC_TRAITS_H_HWIWA6G0 #include "rpc/detail/bool.h" namespace rpc { namespace detail { template using is_zero = invoke>; template using nth_type = invoke>>; namespace tags { // tags for the function traits, used for tag dispatching struct zero_arg {}; struct nonzero_arg {}; struct void_result {}; struct nonvoid_result {}; template struct arg_count_trait { typedef nonzero_arg type; }; template <> struct arg_count_trait<0> { typedef zero_arg type; }; template struct result_trait { typedef nonvoid_result type; }; template <> struct result_trait { typedef void_result type; }; } //! \brief Provides a small function traits implementation that //! works with a reasonably large set of functors. template struct func_traits : func_traits {}; template struct func_traits : func_traits {}; template struct func_traits : func_traits {}; template struct func_traits { using result_type = R; using arg_count = std::integral_constant; using args_type = std::tuple::type...>; }; template struct func_kind_info : func_kind_info {}; template struct func_kind_info : func_kind_info {}; template struct func_kind_info : func_kind_info {}; template struct func_kind_info { typedef typename tags::arg_count_trait::type args_kind; typedef typename tags::result_trait::type result_kind; }; template using is_zero_arg = is_zero::arg_count>; template using is_single_arg = invoke::arg_count == 1, true_, false_>>; template using is_void_result = std::is_void::result_type>; } } #endif /* end of include guard: FUNC_TRAITS_H_HWIWA6G0 */