#ifndef LIBSRK31CXX_UTIL_HPP_ #define LIBSRK31CXX_UTIL_HPP_ /* This is a hack. "using" is a better C++11 feature to use, but g++ doesn't support it yet. */ #define forward_constructors(base_typename, this_typename) \ template \ this_typename(Args&&... args) \ : base_typename(std::forward(args)...) {} /* This is something that really should be in C++1x. * Thanks to T.C.: * https://stackoverflow.com/questions/27879815/c11-get-type-of-first-second-etc-argument-similar-to-result-of#27885283 */ // primary template. template struct function_traits : function_traits { }; // partial specialization for function type template struct function_traits { using result_type = R; using argument_types = std::tuple; }; // partial specialization for function pointer template struct function_traits { using result_type = R; using argument_types = std::tuple; }; // partial specialization for std::function template struct function_traits> { using result_type = R; using argument_types = std::tuple; }; // partial specialization for pointer-to-member-function (i.e., operator()'s) template struct function_traits { using result_type = R; using argument_types = std::tuple; }; template struct function_traits { using result_type = R; using argument_types = std::tuple; }; template using first_argument_type = typename std::tuple_element<0, typename function_traits::argument_types>::type; #endif