Re: Compilation Bug in Quantlib Array

Posted by Bill Shortall on
URL: http://quantlib.414.s1.nabble.com/Date-problem-in-swaptionhelper-cpp-tp2210p2214.html

Hi Luigi,

Here is the error message it points to the line where
   std::ptr_fun(QL_FABS)  appears  and only happens in release mode
not in debug and when expression templates are off

Compiling...
main.cpp
C:\Cprogs\Expression Templates\Quantlib\array.h(1343) : error C2780: '_OI
__cdecl std::transform(_II1,_II1,_II2,_OI,_Bop)' : expects 5 arguments - 4
provided
        C:\Language\Microsoft Visual Studio\VC98\INCLUDE\algorithm(247) :
see declaration of 'transform'
Error executing cl.exe.

msft1.exe - 1 error(s), 0 warning(s)


----- Original Message -----
From: "Luigi Ballabio" <[hidden email]>
To: "Bill" <[hidden email]>; <[hidden email]>
Sent: Sunday, September 29, 2002 7:07 AM
Subject: Re: [Quantlib-users] Compilation Bug in Quantlib Array


>
> Hi Bill,
>
> At 11:08 AM -0400 9/28/02, Bill wrote:
> >  I am experiencing compilation problems with
> >  Microsoft VC6 on quantlib section Array.h.
> >  I believe the problem is in the std::ptr_fun  it won't run in
> >  release mode  gives strange error messages like not enough
> >  arguments.
>
> Hmm. Could you send me the error, to see if I can make head or tail of it?
>
>
> >Since its function is to make abs derive from
> >  std::unary function the trick is to do it the long way.
> >  Replace the above code with
> >
> >
> >   template <class T1, class T2>
> >   struct qlfabs : public std::unary_function<T1, T2>
> >   {  T1 operator() (T2 x ) const
> >    {return ::abs(x) ; }
> >   };
> >
> >         inline Array Abs(const Array& v) {
> >             Array result(v.size());
> >             std::transform(v.begin(),v.end(),result.begin(),
> >                 //std::ptr_fun(QL_FABS));
> >         qlfabs<double, double>());
> >             return result;
> >         }
> >
> >
> >   You also have to do this with Sqrt, Log,and Exp.
>
> Well, the purpose of using std::ptr_fun was brevity. If it gives
> problems, I guess the next simplest way would be to write
>
>          inline Array Abs(const Array& v) {
>              Array result(v.size());
>              for (unsigned i=0; i<v.size(); i++)
>                  result[i] = QL_FABS(v[i]);
>              return result;
>          }
>
> Thanks for the report,
> Luigi
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Quantlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>