'std :: vector':'U64'不是参数'_Ty'的有效模板类型参数

时间:2015-02-12 19:19:11

标签: c++ templates vector compiler-errors

我有一个包含

的标题SomeDefines.h
#define U64 unsigned long long
#define U16 unsigned short

在Myclass.h中,我#include SomeDefines.h位于顶部。

在Myclass声明中,我有一个函数

bool someFunc(const std::vector<U64>& theVector);

和一个成员变量     tbb :: atomic someNumber;

当我在Visual Studio 2012中编译时,我得到了错误

error: 'U64': undeclared identifier
error C2923: 'std::vector': 'U64' is not a valid template type argument for parameter '_Ty'

如果我将U64替换为unsigned long long

,错误就会消失
bool someFunc(const std::vector<unsigned long long>& theVector);

我认为编译器会看到#define U64 unsigned long long并将U64替换为unsigned long long

为什么我会为U64而不是U16

收到这些错误

1 个答案:

答案 0 :(得分:0)

#define不是创建新类型的好主意。首选typedefusing

typedef unsigned long long U64;
// or:
using U64 = unsigned long long;