no uniquely matching class member found for a template instanciation

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

I have a class with a templated function. The function is specialized/instanciated so it can be defined in the cpp. Doxygen gives me an error about the template instanciation.

For example, my .h:

namespace LP {     namespace LF     {         class FileReader         {         public:             template <class T> void Read( T *aValue );             size_t Read( uint8_t *aBuffer, size_t aSizeToRead );         };     } } 

And my cpp:

/// Valid doxygen function doc template<class T> void LP::LF::FileReader::Read( T *aValue ) {     Read( reinterpret_cast<uint8_t *>( aValue ), sizeof( T ) ); }  //Template specialisation so it can be defined in the cpp file template void LP::LF::FileReader::Read<uint8_t>( uint8_t * ); template void LP::LF::FileReader::Read<uint16_t>( uint16_t * ); template void LP::LF::FileReader::Read<uint32_t>( uint32_t * ); 

I got this error for all 3 lines of specialization:

warning: no uniquely matching class member found for    template void LP::LF::FileReader::Read< uint8_t >(uint8_t *) Possible candidates:   'template < T >   void LP::LF::FileReader::Read(T *aValue)' at line 48 of file FileReader.h   size_t LP::LF::FileReader::Read(uint8_t *aBuffer, size_t aSizeToRead)' at line 49 of file FileReader.h 

If I rename one of the Read functions, it fixes the error, but I would prefer not to do it.

The specialization dont need to be documented, the generic function is already documented

doxygen 1.8.13

Thanks

EDIT: changed title to instanciation from specialization

回答1:

Didnt find a correct syntax, but a kind of workaround:

/// \relates LP::LF::FileReader template void LP::LF::FileReader::Read<uint8_t>( uint8_t * ); 

Not sure why, but it silences the warning



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!