gpt4 book ai didi

c++ - 在模板参数中将 const unsigned int 转换为 unsigned int

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:35:14 24 4
gpt4 key购买 nike

使用以下代码:

#include <iostream>

template< class T, unsigned int NVectorDimension = 3 >
class Vector
{
};

template< unsigned int TDimension >
int RunTest( void )
{
const unsigned int VectorDimension = 4;
typedef Vector< int, VectorDimension > VectorPixelType;
}

int main(int argc, char *argv[])
{

return 0;
}

我得到:

In function ‘int RunTest()’:
12:40: error: could not convert template argument ‘VectorDimension’ to ‘unsigned int’
error: invalid type in declaration before ‘;’ token

知道这有什么问题吗?

大卫

最佳答案

gcc 确实有一个错误。现在已经修复: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48657

关于c++ - 在模板参数中将 const unsigned int 转换为 unsigned int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5697546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com