作为继续:单个函数的两个可变参数模板?
我需要一个带有两个可变类型列表的函数。
例子:
template<typename... Types, typename... Args>
void function(Args&&... args) {
...
}
// usage
function</* types list for Types variadic */>(1,2,3/* arguments for Args */)
谢谢。
作为继续:单个函数的两个可变参数模板?
我需要一个带有两个可变类型列表的函数。
例子:
template<typename... Types, typename... Args>
void function(Args&&... args) {
...
}
// usage
function</* types list for Types variadic */>(1,2,3/* arguments for Args */)
谢谢。
这应该只是工作:
#include <type_traits>
#include <tuple>
template<typename... Types, typename... Args>
void fxn(Args&&... args) {
static_assert(
std::is_same<std::tuple<Types...>, std::tuple<int, bool>>::value, "!");
static_assert(
std::is_same<std::tuple<Args...>, std::tuple<int, double, char>>::value, "!");
}
int main()
{
fxn<int, bool>(42, 3.14, 'c');
}