Boost logo

Boost :

From: Steven Youngs (steve_at_[hidden])
Date: 2000-10-19 09:49:25


From memory, MSVC decorates functions using their arguments and return type.
Hence if the member template function uses all of the template types in its
argument list and return type it is correctly decorated. Otherwise the
decoration will not be unique which, as Dave alluded, causes incorrect
linkage.
There's a Microsoft KnowledgeBase article about this "BUG: Explicitly
Specified Template Functions Not Overloaded Correctly"

The example code they give uses non-member templated functions but I'm
pretty sure from my own experimentation that the same applies to member
template functions to

Steve

--
Steven Youngs
NC Graphics Ltd.
Microsoft Example code:
#include<iostream>
//#define WORKAROUND
#ifdef WORKAROUND
template <class T>
void f(T dummy = 0)
     {
     std::cout <<typeid(T).name() <<std::endl;
     }
#else
template <class T>
void f(void)
     {
     std::cout <<typeid(T).name() <<std::endl;
     }
#endif
int main(void)
     {
     f<bool>();
     f<char>();
     f<int>();
     return 0;
     }
Output :
int
int
int
----- Original Message -----
From: "David Abrahams" <abrahams_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, October 19, 2000 3:45 PM
Subject: Re: [boost] shared_ptr hierarchy question
> We once were about to turn off BOOST_NO_MEMBER_TEMPLATES for MSVC, but
then
> someone supposedly found a linker (!) problem caused by the use of member
> templates. I've never been able to figure out whether that was a phantom
> issue (perhaps caused by an out-of-date compiler) or a real one. If anyone
> has a reproducible case of this it would be great if we could capture it
for
> the website as documentation of why we have the special
> BOOST_MSVC_MEMBER_TEMPLATES define. Otherwise, we should probably just
> enable member templates for MSVC.
>
> -Dave
>
> ----- Original Message -----
> From: "Peter Dimov" <pdimov_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Thursday, October 19, 2000 10:22 AM
> Subject: Re: [boost] shared_ptr hierarchy question
>
>
> > > I'm going to assume now that you're using MSVC, which won't compile
> > the
> > > above.  Trying to think of a workaround... um... I dunno!  Anyone else
> > got
> > > some bright ideas?
> >
> > Yes, BOOST_NO_MEMBER_TEMPLATES is defined for MSVC, but the compiler can
> > cope with the member templates in smart_ptr.hpp. The only caveat is that
> > the template must come _before_ the non-template.
> >
> > I've attached a modified smart_ptr.hpp that passes your test.
> >
> > --
> > Peter Dimov
> > Multi Media Ltd.
> >
> >
> >
>
>
>
>
>

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk