]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/spirit/home/x3/support/numeric_utils/sign.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / spirit / home / x3 / support / numeric_utils / sign.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2014 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(BOOST_SPIRIT_X3_SIGN_MAR_11_2009_0734PM)
10 #define BOOST_SPIRIT_X3_SIGN_MAR_11_2009_0734PM
11
12 #include <boost/config/no_tr1/cmath.hpp>
13 #include <boost/math/special_functions/fpclassify.hpp>
14 #include <boost/math/special_functions/sign.hpp>
15
16 namespace boost { namespace spirit { namespace x3
17 {
18 template<typename T>
19 inline bool (signbit)(T x)
20 {
21 return (boost::math::signbit)(x) ? true : false;
22 }
23
24 // This routine has been taken and adapted from Johan Rade's fp_traits
25 // library
26 template<typename T>
27 inline T (changesign)(T x)
28 {
29 #if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)
30 return -x;
31 #else
32 typedef typename math::detail::fp_traits<T>::type traits_type;
33
34 typename traits_type::bits a;
35 traits_type::get_bits(x, a);
36 a ^= traits_type::sign;
37 traits_type::set_bits(x, a);
38 return x;
39 #endif
40 }
41
42 }}}
43
44 #endif