Hi Dimitri!

Thanks for the quick answer.

You are right, the provided code does not compile. The modified example now is

//! a test class with overloaded template members
class Bar
{
public:
  //! first overload of template member function
  template <typename T>
  T foo(T a, int b)
  { return a; }

  //! second overload of template member function
  template <typename T>
  T foo(T a, double c)
  { return a; }
};

//! force instantiation of first overload for type 'short'
template short Bar::foo<short>(short, int);

If you compile this using
gcc -c bar.cpp

the corresponding object file will contain exactly one symbol (which you can 
see using nm). This is exactly what is intended (to force the creation of a 
symbol for a specific template parameter).

The syntax you suggested refers to a different concept, namely "template 
specialization". In that case, the statement
  template<> short Bar::foo<short>(short, int);
is a function declaration, which would require a separate function definition 
in order to create a corresponding symbol. If I would compile the modified 
example with your suggestion, then the corresponding object file does not 
contain any symbols (which is not what is intended).

Best regards,
Harald


-----Original Message-----
From: Dimitri van Heesch [mailto:doxy...@gmail.com]
Sent: Wednesday, August 26, 2015 4:04 PM
To: Heese, Harald
Cc: doxygen-users@lists.sourceforge.net
Subject: Re: [Doxygen-users] warning at explicit instantiation of overloaded 
template class member function

Hi Harald,

> On 26 Aug 2015, at 15:19 , Heese, Harald <harald.he...@philips.com> wrote:
>
> Hi doxygen,
>
> I am encountering warnings using Doxygen 1.8.10 for the below example of 
> overloaded template member functions with explicit instantiation of one (or 
> more) of the overloads for specific template types.
>
> //! a test class with overloaded template members class Bar {
> public:
>  //! first overload of template member function  template <typename T>
> T foo(T a, int b);
>
>  //! second overload of template member function  template <typename
> T>  T foo(T a, double c); };
>
> //! force instantiation of first overload for type 'short'
> template short Bar::foo<short>(short, int);
>
> Output
>
> warning: no matching class member found for  template short Bar::foo<
> short >(short, int) Possible candidates:
>  'template < T >
>  T Bar::foo(T a, int b)
>  'template < T >
>  T Bar::foo(T a, double c)
>
> Is there a way to incorporate the existence of an explicit instantiation (or 
> its accompanying doxygen documentation) in the detailed documentation of the 
> class member (which happens if there are no overloads)?

If you use

//! force instantiation of first overload for type 'short'
template<> short Bar::foo<short>(short, int);

it should work. Note the <> after template. My compiler doesn't even compile 
the code without it.

Groeten,
  Dimitri


________________________________
The information contained in this message may be confidential and legally 
protected under applicable law. The message is intended solely for the 
addressee(s). If you are not the intended recipient, you are hereby notified 
that any use, forwarding, dissemination, or reproduction of this message is 
strictly prohibited and may be unlawful. If you are not the intended recipient, 
please contact the sender by return e-mail and destroy all copies of the 
original message.

------------------------------------------------------------------------------
_______________________________________________
Doxygen-users mailing list
Doxygen-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/doxygen-users

Reply via email to