David Levy
David Levy

Reputation: 511

no uniquely matching class member found for a template instanciation

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

Upvotes: 4

Views: 952

Answers (1)

David Levy
David Levy

Reputation: 511

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

Upvotes: 6

Related Questions