我有這樣的代碼:在認定中,以template<typename SceneT, GeneratorType TYPE>
型enum-錯誤的NoType在模板的專業化:模板參數無效
enum GeneratorType
{
FILE_LIST, DEVICE
};
template<typename SceneT, int TYPE>
class ODFrameGenerator
{
//... some APIS
};
template<typename SceneT>
class ODFrameGenerator<SceneT, GeneratorType::DEVICE>
{
//...specialization: ERROR: template argument 2 is invalid
};
template<typename SceneT>
class ODFrameGenerator<SceneT, 1>
{
//...specialization: compiles fine!!
};
我試圖改變template<typename SceneT, int TYPE>
但仍北京時間給出確切的同樣的錯誤。任何想法什麼是錯的,以及如何避免這種情況?
注意:這是編譯與c + + 11(與-std = c + + 11標誌);但是否則失敗。我正在使用gcc 4.9.2。
編輯:確切的錯誤我得到的是以下幾點:
/home/sarkar/opendetection/common/utils/ODFrameGenerator.h:80:61: error: template argument 2 is invalid
class ODFrameGenerator<ODSceneImage, GeneratorType::DEVICE>
^
/home/sarkar/opendetection/common/utils/ODFrameGenerator.h:100:46: error: wrong number of template arguments (1, should be 2)
class ODFrameGenerator<ODScenePointCloud<> >, GeneratorType::DEVICE>
^
/home/sarkar/opendetection/common/utils/ODFrameGenerator.h:28:9: error: provided for ‘template<class SceneT, int TYPE> class od::ODFrameGenerator’
class ODFrameGenerator
^
/home/sarkar/opendetection/examples/objectdetector/od_image_camera.cpp: In function ‘int main(int, char**)’:
/home/sarkar/opendetection/examples/objectdetector/od_image_camera.cpp:28:67: error: template argument 2 is invalid
od::ODFrameGenerator<od::ODSceneImage, od::GeneratorType::DEVICE> frameGenerator("0");
^
/home/sarkar/opendetection/examples/objectdetector/od_image_camera.cpp:28:83: error: invalid type in declaration before ‘(’ token
od::ODFrameGenerator<od::ODSceneImage, od::GeneratorType::DEVICE> frameGenerator("0");
是您獲得的* exact *錯誤嗎?它是*完整*嗎? *未經編輯*? –
@JoachimPileborg,我添加了我得到的確切的錯誤。 – krips89