Im a little stuck.
Trying to check if a argument is a reference type from inside my template class
It seems to work in the function.
But inside my function wrapper its always returning true.
#include <vector>
#include <any>
template <class T>
T CallFunction(const std::vector<std::any>& args) {
for (size_t i = args.size(); i > 0; i--) {
std::cout << std::boolalpha << std::is_reference<decltype(args[i-1].type())>::value << std::endl; // always true
}
return T();
}
template<typename Fn> class FunctionBase;
template<typename R, typename... Args>
class FunctionBase <R(__cdecl*)(Args...)> {
public:
FunctionBase() {}
R operator()(Args... args) {
return CallFunction<R>({ args ... });
}
};
int foo(int a, int& b) {
std::cout << std::boolalpha << std::is_reference<decltype(a)>::value << std::endl; // falae
std::cout << std::boolalpha << std::is_reference<decltype(b)>::value << std::endl; // true
return a + b;
}
int main() {
int in = 10;
foo(1, in);
FunctionBase<decltype(&foo)> func;
func(1, in);
}