PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/spirit/home/support/detail/sign.hpp

http://hadesmem.googlecode.com/
C++ Header | 71 lines | 50 code | 8 blank | 13 comment | 1 complexity | a1667415604ef4092e9dfc5ac58e1f32 MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2001-2011 Joel de Guzman
 3    Copyright (c) 2001-2011 Hartmut Kaiser
 4    http://spirit.sourceforge.net/
 5
 6    Distributed under the Boost Software License, Version 1.0. (See accompanying
 7    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 8=============================================================================*/
 9#if !defined(SPIRIT_SIGN_MAR_11_2009_0734PM)
10#define SPIRIT_SIGN_MAR_11_2009_0734PM
11
12#if defined(_MSC_VER)
13#pragma once
14#endif
15
16#include <boost/config/no_tr1/cmath.hpp>
17#include <boost/version.hpp>
18#if BOOST_VERSION < 104000 
19#include <boost/spirit/home/support/detail/math/fpclassify.hpp>
20#include <boost/spirit/home/support/detail/math/signbit.hpp>
21#else
22#include <boost/math/special_functions/fpclassify.hpp>
23#include <boost/math/special_functions/sign.hpp>
24#endif
25
26namespace boost { namespace spirit { namespace detail
27{
28#if BOOST_VERSION < 104000
29    // signbit(-NAN) is broken for versions of Boost earlier than 1.40.0
30    // This routine has been taken and adapted from Johan Rade's fp_traits 
31    // library
32    template<typename T> 
33    inline bool (signbit)(T x)
34    {
35        return (boost::spirit::math::signbit)(x);
36    }
37
38    template<typename T> 
39    inline T (changesign)(T x)
40    {
41        return (boost::spirit::math::changesign)(x);
42    }
43#else
44    template<typename T> 
45    inline bool (signbit)(T x)
46    {
47        return (boost::math::signbit)(x) ? true : false;
48    }
49
50    // This routine has been taken and adapted from Johan Rade's fp_traits 
51    // library
52    template<typename T> 
53    inline T (changesign)(T x)
54    {
55#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)
56        return -x;
57#else
58        typedef typename math::detail::fp_traits<T>::type traits_type;
59
60        typename traits_type::bits a;
61        traits_type::get_bits(x, a);
62        a ^= traits_type::sign;
63        traits_type::set_bits(x, a);
64        return x;
65#endif
66    }
67#endif
68
69}}}
70
71#endif