调用Microsoft :: WRL :: Make用于具有9个以上参数的构造函数

时间:2016-05-14 10:43:53

标签: c++ windows-runtime wrl

Microsoft::WRL::Make seems to be defined with a maximum of 9 arguments that will get forwarded to the object's constructorstd::tuple是一个明显的解决方案,但远非理想。有没有更优雅的方法来解决这个问题?

如果WRL的任何维护者都在潜伏,请向Make(以及RuntimeClass等添加可变参数模板支持,等等)

1 个答案:

答案 0 :(得分:0)

FWIW,这是我目前的工作解决方案:

template <typename... Types>
MyClass(std::tuple<Types...> args) :
    MyClass(args, std::make_integer_sequence<size_t, sizeof...(Types)>())
{
}

template <typename... Types, size_t... Indices>
MyClass(std::tuple<Types...>& args, std::integer_sequence<size_t, Indices...>) :
    MyClass(std::get<Indices>(std::move(args))...)
{
}

构建
auto ptr = Make<MyClass>(std::forward_as_tuple(...));

远非理想,但最糟糕的情况是它会......