This is template for holding class member method signature. It has no default implementation, but have specialized for every case when method has or has not c-style variadic parameters and has or has not all combinations of cv-qualifiers. And all these things yields 8 very similar pieces of code. Could anyone suggest some method to shrink this template:
#include <type_traits>
template <typename ... args>
struct params_t
{
// ...
};
template <typename T>
struct mem_fn_t;
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... )>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... );
typedef typename std::remove_pointer<pfunction>::type function;
};
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... ) const>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... ) const;
typedef typename std::remove_pointer<pfunction>::type function;
};
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... ) volatile>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... ) volatile;
typedef typename std::remove_pointer<pfunction>::type function;
};
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... ) const volatile>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... ) const volatile;
typedef typename std::remove_pointer<pfunction>::type function;
};
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... , ... )>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... , ... );
typedef typename std::remove_pointer<pfunction>::type function;
};
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... , ... ) const>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... , ... ) const;
typedef typename std::remove_pointer<pfunction>::type function;
};
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... , ... ) volatile>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... , ... ) volatile;
typedef typename std::remove_pointer<pfunction>::type function;
};
template <typename class_t, typename ret_val_t, typename ... args>
struct mem_fn_t<ret_val_t (class_t::*)(args ... , ... ) const volatile>
{
typedef class_t class_type;
typedef ret_val_t result_type;
typedef params_t<args...> params_type;
typedef result_type (class_type::*pfunction)(args ... , ... ) const volatile;
typedef typename std::remove_pointer<pfunction>::type function;
};