the following code can not be compiled in VC6 ,but can be compiled in
VC.net2003

Is there any way that make vc6 to support STL better?



#include <iostream>
#include <vector>

using namespace std;


class myc
{
public:
myc():v(5){}
template<class myiter>
void tmpfunc(myiter first,myiter last,int i);
void fun();
private:
vector<int> v;
};

template<class myiter>
void myc::tmpfunc(myiter first,myiter last,int i)
{
for(;first!=last;++first)
{
cout<<*first;
}
cout<<endl;
}

void myc::fun()
{
tmpfunc(v.begin(),v.end(),0);
/*
in vc6 ,there is an error:
G:\myproject\con0002\con002.cpp(30) : error C2893: Failed to specialize
function template 'void __thiscall myc::tmpfunc(myiter,myiter,int)'
With the following template arguments:
'int *'
*/
}


int main()
{
myc m;
m.fun();

return 0;
}

Re: question about STL on VC6 by Igor

Igor
Sun Aug 21 07:41:20 CDT 2005

"howyougen" <isqlw@sina.com> wrote in message
news:eCGvMhkpFHA.2580@TK2MSFTNGP09.phx.gbl
> the following code can not be compiled in VC6 ,but can be compiled in
> VC.net2003
>
> Is there any way that make vc6 to support STL better?

The problem has nothing to do with STL, but with VC6's less than stellar
support of templates. Among other things, VC6 does not support
out-of-class definition of member templates. Just move the
implementation of tmpfunc into the class, and it'll compile.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: question about STL on VC6 by howyougen

howyougen
Sun Aug 21 07:59:02 CDT 2005

thanks so much!


"Igor Tandetnik" <itandetnik@mvps.org> дÈëÏûÏ¢ÐÂÎÅ:%23A1Mg2kpFHA.320@TK2MSFTNGP09.phx.gbl...
> "howyougen" <isqlw@sina.com> wrote in message
> news:eCGvMhkpFHA.2580@TK2MSFTNGP09.phx.gbl
>> the following code can not be compiled in VC6 ,but can be compiled in
>> VC.net2003
>>
>> Is there any way that make vc6 to support STL better?
>
> The problem has nothing to do with STL, but with VC6's less than stellar
> support of templates. Among other things, VC6 does not support
> out-of-class definition of member templates. Just move the implementation
> of tmpfunc into the class, and it'll compile.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>