@Jarod42, . - , int, , :
template<typename ref, typename t, typename ...types>
struct all_same {
static constexpr bool value = std::is_same<ref, t>::value && all_same<ref, types...>::value;
};
template<typename ref, typename t>
struct all_same<ref, t> {
static constexpr bool value = std::is_same<ref, t>::value;
};
, . Invoke params args...:
template<typename ... Args>
void Invoke(const char* funcName, Args ... args)
{
using params_type = typename std::conditional<all_same<int, Args...>::value, int, SPrimitive>::type;
params_type params[] = { args ... };
SomeOtherInvoke(funcName, params, sizeof ... (Args));
}
:
struct SPrimitive{
};
void SomeOtherInvoke(const char*, SPrimitive*, size_t) {
std::cout << "Invoked for SPrimitive\n";
}
void SomeOtherInvoke(const char*, int*, size_t) {
std::cout << "Invoked for int\n";
}
Invoke("foo", SPrimitive());
Invoke("foo", SPrimitive(), SPrimitive());
Invoke("foo", 1, 2, 3, 4);
:
Invoked for SPrimitive
Invoked for SPrimitive
Invoked for int
.