error C2825: 'F': must be a class or namespace when followed by '::'

Dear Users, I am using a pointer to a function member with the std::transform alorithm. The class is a QuantLib class called DayCounter and the method is called yearFraction and takes in two mandatory dates and two optionals to return the corresponding year fraction. *yearFraction ( QuantLib::Date t1,QuantLib::Date t2,QuantLib::Date t3 = Date(),QuantLib::Date t4=Date())* Now I tried to fill a vector called yearfracs in this way boost::shared_ptrQuantLib::DayCounter dc( new QuantLib::ActualActual); QuantLib::Date t = todaysDate() std::vectorQuantLib::Time yearfracs; std::transform(subsample.begin(),subsample.end(), yearfracs.begin(),boost::bind(&QuantLib::ActualActual::yearFraction,&dc,t,_2)) subsample is the originary vector of dates. The compiler reported the following error error C2825: 'F': must be a class or namespace when followed by '::' What is the correct syntax for doing this? Thanks in advance Simone

simone pilozzi wrote:
Dear Users,
I am using a pointer to a function member with the std::transform alorithm. The class is a QuantLib class called DayCounter and the method is called yearFraction and takes in two mandatory dates and two optionals to return the corresponding year fraction.
/yearFraction ( QuantLib::Date t1,QuantLib::Date t2,QuantLib::Date t3 = Date(),QuantLib::Date t4=Date())/
Now I tried to fill a vector called yearfracs in this way
boost::shared_ptrQuantLib::DayCounter dc( new QuantLib::ActualActual);
QuantLib::Date t = todaysDate()
std::vectorQuantLib::Time yearfracs;
std::transform(subsample.begin(),subsample.end(),
yearfracs.begin(),boost::bind(&QuantLib::ActualActual::yearFraction,&dc,t,_2))
Assuming you want each subsample item to be pass as t2 : boost::bind (&QuantLib::ActualActual::yearFraction ,&dc ,t ,_1 , QuantLib::Date() , QuantLib::Date()) You need the _1, as you are generating a unary function object. IIRC, you need to specify the default args. Also I assume yearFracs.size() >= subsamble.size()? Jeff

Thanks for your swift reply.
Yes,it is of the same size, I must change the line
std::vectorQuantLib::Time yearfracs(subsample.size())
Thanks again
On 20 April 2011 19:23, Jeff Flinn
simone pilozzi wrote:
Dear Users, I am using a pointer to a function member with the std::transform alorithm. The class is a QuantLib class called DayCounter and the method is called yearFraction and takes in two mandatory dates and two optionals to return the corresponding year fraction. /yearFraction ( QuantLib::Date t1,QuantLib::Date t2,QuantLib::Date t3 = Date(),QuantLib::Date t4=Date())/ Now I tried to fill a vector called yearfracs in this way boost::shared_ptrQuantLib::DayCounter dc( new QuantLib::ActualActual);
QuantLib::Date t = todaysDate()
std::vectorQuantLib::Time yearfracs;
std::transform(subsample.begin(),subsample.end(),
yearfracs.begin(),boost::bind(&QuantLib::ActualActual::yearFraction,&dc,t,_2))
Assuming you want each subsample item to be pass as t2 :
boost::bind (&QuantLib::ActualActual::yearFraction ,&dc ,t ,_1 , QuantLib::Date() , QuantLib::Date())
You need the _1, as you are generating a unary function object. IIRC, you need to specify the default args.
Also I assume yearFracs.size() >= subsamble.size()?
Jeff
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Thanks it compiles
On 20 April 2011 19:23, Jeff Flinn
simone pilozzi wrote:
Dear Users, I am using a pointer to a function member with the std::transform alorithm. The class is a QuantLib class called DayCounter and the method is called yearFraction and takes in two mandatory dates and two optionals to return the corresponding year fraction. /yearFraction ( QuantLib::Date t1,QuantLib::Date t2,QuantLib::Date t3 = Date(),QuantLib::Date t4=Date())/ Now I tried to fill a vector called yearfracs in this way boost::shared_ptrQuantLib::DayCounter dc( new QuantLib::ActualActual);
QuantLib::Date t = todaysDate()
std::vectorQuantLib::Time yearfracs;
std::transform(subsample.begin(),subsample.end(),
yearfracs.begin(),boost::bind(&QuantLib::ActualActual::yearFraction,&dc,t,_2))
Assuming you want each subsample item to be pass as t2 :
boost::bind (&QuantLib::ActualActual::yearFraction ,&dc ,t ,_1 , QuantLib::Date() , QuantLib::Date())
You need the _1, as you are generating a unary function object. IIRC, you need to specify the default args.
Also I assume yearFracs.size() >= subsamble.size()?
Jeff
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

It was that an the optional inputs
Thanks
On 20 April 2011 19:32, Igor R
yearfracs.begin(),boost::bind(&QuantLib::ActualActual::yearFraction,&dc,t,_2))
should be _1 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Igor R
-
Jeff Flinn
-
simone pilozzi