The code is meant to solve this problem: If we know a signature and bind params for the first n params, get the new call signature if first n params are bounded.
But gcc gives error when I try this compile the code.
a.cc:23:62: error: expected ‘;’ before ‘<’ token
using signature = typename GetSignature<R(Args...)>::Bind<BArgs...>::signature;
I have no ideal why there is such error.
Here is the code:
#include <type_traits>
template<typename T>
struct GetSignature {
using signature = typename T::signature;
};
template<typename R>
struct GetSignature<R(void)> {
template<typename... Args>
struct Bind {
using signature = R(void);
};
};
template<typename R, typename Arg, typename... Args>
struct GetSignature<R(Arg, Args...)> {
template<typename... BArgs> struct Bind;
template<typename BArg, typename... BArgs>
struct Bind<BArg, BArgs...> {
static_assert(std::is_same<Arg, BArg>::value);
using signature = typename GetSignature<R(Args...)>::Bind<BArgs...>::signature;
};
template<typename BArg>
struct Bind<BArg> {
using signature = R(Args...);
};
};
int func(bool, double, int, char);
int main() {
// GetSignature<func>::Bind<bool, double>::signature should be int(int, char)
return 0;
}