问题描述
尝试将通用引用与CTAD和参数包一起使用,我尝试了以下类似方法,但是它不能在MinGW GCC上编译。而且我不明白为什么。 这是示例代码:
#include <utility>
template<typename... Ts>
struct Subtest
{
Subtest(Ts...) {}
};
template<typename... Ts>
struct Test
{
template<typename... Us>
Test( Us&&... values1 )
: values( std::forward<Us>( values1 )... )
{}
Subtest<Ts...> values;
};
template<typename... Ts>
Test(Ts&&...) -> Test<std::remove_reference_t<Ts>...>;
int main()
{
Test t(12,14);
return 0;
}
这些是错误:
main.cpp: In instantiation of 'Test<Ts>::Test(Us&& ...) [with Us = {int,int}; Ts = {}]':
main.cpp:26:18: required from here
main.cpp:14:46: error: no matching function for call to 'Subtest<>::Subtest(int,int)'
14 | : values( std::forward<Us>( values1 )... )
| ^
main.cpp:6:5: note: candidate: 'Subtest<Ts>::Subtest(Ts ...) [with Ts = {}]'
6 | Subtest(Ts...) {}
| ^~~~~~~
main.cpp:6:5: note: candidate expects 0 arguments,2 provided
main.cpp:4:8: note: candidate: 'constexpr Subtest<>::Subtest(const Subtest<>&)'
4 | struct Subtest
| ^~~~~~~
main.cpp:4:8: note: candidate expects 1 argument,2 provided
main.cpp:4:8: note: candidate: 'constexpr Subtest<>::Subtest(Subtest<>&&)'
main.cpp:4:8: note: candidate expects 1 argument,2 provided
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)