Ticket #46721: patch-src-tools-ParseExp.cpp.diff

File patch-src-tools-ParseExp.cpp.diff, 2.2 KB (added by ryandesign (Ryan Carsten Schmidt), 10 years ago)
  • src/tools/ParseExp.cpp

    Fix build with boost 1.56.0 and later
    https://sourceforge.net/p/hugin/hugin/ci/e237d6d1d87354f974d37a95ba52dbd9666dd310/
    old new  
    3434#include <limits>
    3535#include <iterator>
    3636
     37#define BOOST_SPIRIT_USE_PHOENIX_V3 1
    3738#include <boost/spirit/version.hpp>
    3839#if !defined(SPIRIT_VERSION) || SPIRIT_VERSION < 0x2010
    3940#error "At least Spirit version 2.1 required"
     
    5051//power function
    5152struct lazy_pow_
    5253{
    53     template <typename X, typename Y>
    54     struct result { typedef X type; };
     54    typedef double result_type;
    5555
    56     template <typename X, typename Y>
    57     X operator()(X x, Y y) const
     56    double operator()(double x, double y) const
    5857    {
    5958        return std::pow(x, y);
    6059    }
     
    6362// modulus for double values
    6463struct lazy_mod_
    6564{
    66     template <typename X, typename Y>
    67     struct result { typedef X type; };
     65    typedef double result_type;
    6866
    69     template <typename X, typename Y>
    70     X operator()(X x, Y y) const
     67    double operator()(double x, double y) const
    7168    {
    7269        return std::fmod(x,y);
    7370    }
     
    7673// if statement
    7774struct lazy_if_
    7875{
    79     template <typename X, typename Y, typename Z>
    80     struct result { typedef Y type; };
     76    typedef double result_type;
    8177
    82     template <typename X, typename Y, typename Z>
    83     X operator()(X x, Y y, Z z) const
     78    double operator()(double x, double y, double z) const
    8479    {
    85         return x ? y : z;
     80        return (std::fabs(x)>1e-5) ? y : z;
    8681    }
    8782};
    8883
    8984// wrapper for unary function
    9085struct lazy_ufunc_
    9186{
    92     template <typename F, typename A1>
    93     struct result { typedef A1 type; };
     87    typedef double result_type;
    9488
    95     template <typename F, typename A1>
    96     A1 operator()(F f, A1 a1) const
     89    double operator()(double (*f)(double), double a1) const
    9790    {
    9891        return f(a1);
    9992    }
    10093};
    10194
    10295// convert rad into deg
    103 double deg(const double d)
     96const double deg(const double d)
    10497{
    10598    return d*180.0/boost::math::constants::pi<double>();
    10699};
    107100
    108101// convert deg into rad
    109 double rad(const double d)
     102const double rad(const double d)
    110103{
    111104    return d*boost::math::constants::pi<double>()/180;
    112105};