I am trying to understand this code and I have found some more SO content on this topic.
In compact form:
#include <tuple>
namespace sqlite {
namespace utility {
template<typename> struct function_traits;
template <typename Function>
struct function_traits : public function_traits<
decltype(&Function::operator())
> { };
template <
typename ClassType,
typename ReturnType,
typename... Arguments
>
struct function_traits<
ReturnType(ClassType::*)(Arguments...) const
> {
typedef ReturnType result_type;
template <std::size_t Index>
using argument = typename std::tuple_element<
Index,
std::tuple<Arguments...>
>::type;
static const std::size_t arity = sizeof...(Arguments);
};
}
}
This led me to learn about the pointer-to-member-function feature of the language, and it's pretty clear to me at this point how to use the function traits (it's fairly straightforward that I can pull out not only the return type but the arity and even the types of the arguments) but I have gotten stuck in understanding why this works, or indeed why it is even possible for it to work...