我将代码简化为这个非常短的示例:
template<class ...F>
struct A
{
A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions);
std::tuple<std::tuple<std::string, F>...> _actions;
};
template<class ...F>
A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
: _actions{ std::tuple{ actions... } }{}
我没觉得有什么问题。但是 clang (-std=c++23) 给出了这个错误:
<source>:13:66: error: pack expansion contains parameter packs 'actions:auto' and 'F' that have different lengths (1 vs. 0)
13 | A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
| ~ ^ ~~~~~~~
<source>:13:10: note: while calculating associated constraint of template '' here
13 | A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
| ^
<source>:13:10: error: out-of-line definition of 'A<F...>' does not match any declaration in 'A<F...>'
13 | A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
| ^
2 errors generated.
这似乎是一个 clang 错误,已在最新的 clang trunk 中修复。 演示