2014-02-11 100 views
0

我有以下类,我需要有两个常量声明。模板类声明 - 不是一个常量表达式

​​

而且 这里是其使用的测试代码

void testBufferPool(const int pageDivSize, const int bufferNum){ 

    // other code and declaration 

    BufferPool <pageDivSize, bufferNum> bufferPool(catalog, devNum, hostCapacityVec, devCapacityVec); 


} 

我收到以下错误:

error: ‘pageDivSize’ is not a constant expression 
BufferPoolTest.cpp:26:39: note: in template argument for type ‘int’ 
BufferPoolTest.cpp:26:39: error: ‘bufferNum’ is not a constant expression 
BufferPoolTest.cpp:26:39: note: in template argument for type ‘int’ 
BufferPoolTest.cpp:26:51: error: invalid type in declaration before ‘(’ token 
BufferPoolTest.cpp:26:100: error: expression list treated as compound expression in initializer [-fpermissive] 
BufferPoolTest.cpp:26:100: error: cannot convert ‘std::vector<long unsigned int>’ to ‘int’ in initialization 

回答