Thread overview
Explicit instantiation and overloading
Jan 14, 2003
Christof Meerwald
Jan 29, 2003
David Thomas
Jan 29, 2003
David Thomas
January 14, 2003
template<class T>
struct A
{
  template<class U>
  void f(const U*)
  { }

  void f()
  { }
};

template void A<char>::f();
// Error: no match for function 'f()'


Found in Boost's regex library - unfortunately, I don't know of a clean workaround...


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de

...and what have you contributed to the Net?
January 29, 2003
Another compiler has generated this error to me and this is my work-around
(maybe this will help you):
template<class T>
struct A
{
   void f();
};

template<class T>
inline void A::f()
{}

template<>
void A<char>::f();


Apparently, the definition of a member function needs to be external to the template class in order to do an explicit declaration of that member function.


"Christof Meerwald" <cmeerw@web.de> wrote in message news:b0218d$1qf3$1@digitaldaemon.com...
> template<class T>
> struct A
> {
>   template<class U>
>   void f(const U*)
>   { }
>
>   void f()
>   { }
> };
>
> template void A<char>::f();
> // Error: no match for function 'f()'
>
>
> Found in Boost's regex library - unfortunately, I don't know of a clean workaround...
>
>
> bye, Christof
>
> --
> http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de
>
> ...and what have you contributed to the Net?


January 29, 2003
I apologize for the name being "news.digitalmars.com".  I didn't realize Outlook Express defaulted it.

"news.digitalmars.com" <dthomas @ cogitoinc.com> wrote in message news:b18udi$1him$1@digitaldaemon.com...
> Another compiler has generated this error to me and this is my work-around
> (maybe this will help you):
> template<class T>
> struct A
> {
>    void f();
> };
>
> template<class T>
> inline void A::f()
> {}
>
> template<>
> void A<char>::f();
>
>
> Apparently, the definition of a member function needs to be external to
the
> template class in order to do an explicit declaration of that member function.
>
>
> "Christof Meerwald" <cmeerw@web.de> wrote in message news:b0218d$1qf3$1@digitaldaemon.com...
> > template<class T>
> > struct A
> > {
> >   template<class U>
> >   void f(const U*)
> >   { }
> >
> >   void f()
> >   { }
> > };
> >
> > template void A<char>::f();
> > // Error: no match for function 'f()'
> >
> >
> > Found in Boost's regex library - unfortunately, I don't know of a clean workaround...
> >
> >
> > bye, Christof
> >
> > --
> > http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de
> >
> > ...and what have you contributed to the Net?
>
>


January 29, 2003
Btw, one does not have to provide a definition to a member function if one wants to force the programmer to provide an explicit instantiation.  That way the linker will let the programmer know that there is no definition available.  I've had occasional need of this.

"news.digitalmars.com" <dthomas @ cogitoinc.com> wrote in message news:b18udi$1him$1@digitaldaemon.com...
> Another compiler has generated this error to me and this is my work-around
> (maybe this will help you):
> template<class T>
> struct A
> {
>    void f();
> };
>
> template<class T>
> inline void A::f()
> {}
>
> template<>
> void A<char>::f();
>
>
> Apparently, the definition of a member function needs to be external to
the
> template class in order to do an explicit declaration of that member function.
>
>
> "Christof Meerwald" <cmeerw@web.de> wrote in message news:b0218d$1qf3$1@digitaldaemon.com...
> > template<class T>
> > struct A
> > {
> >   template<class U>
> >   void f(const U*)
> >   { }
> >
> >   void f()
> >   { }
> > };
> >
> > template void A<char>::f();
> > // Error: no match for function 'f()'
> >
> >
> > Found in Boost's regex library - unfortunately, I don't know of a clean workaround...
> >
> >
> > bye, Christof
> >
> > --
> > http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de
> >
> > ...and what have you contributed to the Net?
>
>