www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Explicit instantiation and overloading

↑ ↓ ← Christof Meerwald <cmeerw web.de> writes:
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?
Jan 14 2003
↑ ↓ "news.digitalmars.com" <dthomas cogitoinc.com> writes:
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?

Jan 29 2003
→ "David Thomas" <dthomas cogitoinc.com> writes:
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

 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?


Jan 29 2003
→ "David Thomas" <dthomas cogitoinc.com> writes:
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

 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?


Jan 29 2003