为超过 9 个参数的构造函数调用 Microsoft::WRL::Make
Calling Microsoft::WRL::Make for a constructor with more than 9 arguments
Microsoft::WRL::Make
seems to be defined with a maximum of 9 arguments that will get forwarded to the object's constructor。 std::tuple
是一个显而易见的解决方案,但远非理想。有没有更优雅的方法解决这个问题?
如果有任何 WRL 维护者潜伏,请在 Make
(以及 RuntimeClass
等)中添加可变模板支持
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(...));
远非理想,但最坏的情况下它会...
Microsoft::WRL::Make
seems to be defined with a maximum of 9 arguments that will get forwarded to the object's constructor。 std::tuple
是一个显而易见的解决方案,但远非理想。有没有更优雅的方法解决这个问题?
如果有任何 WRL 维护者潜伏,请在 Make
(以及 RuntimeClass
等)中添加可变模板支持
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(...));
远非理想,但最坏的情况下它会...