Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 14, 2003 Explicit instantiation and overloading | ||||
---|---|---|---|---|
| ||||
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 Re: Explicit instantiation and overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | 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 Re: Explicit instantiation and overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to news.digitalmars.com | 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 Re: Explicit instantiation and overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to news.digitalmars.com | 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? > > |
Copyright © 1999-2021 by the D Language Foundation