Chris@16
|
1 // (C) Copyright John Maddock 2005.
|
Chris@16
|
2 // Use, modification and distribution are subject to the
|
Chris@16
|
3 // Boost Software License, Version 1.0. (See accompanying file
|
Chris@16
|
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_TR1_MATH_OVERLOADS_HPP_INCLUDED
|
Chris@16
|
7 # define BOOST_TR1_MATH_OVERLOADS_HPP_INCLUDED
|
Chris@16
|
8 # include <boost/config.hpp>
|
Chris@16
|
9
|
Chris@16
|
10 # ifndef BOOST_NO_SFINAE
|
Chris@16
|
11 # include <boost/utility/enable_if.hpp>
|
Chris@16
|
12 # include <boost/type_traits/is_convertible.hpp>
|
Chris@16
|
13 # define BOOST_TR1_MATH_RETURN(RET) typename ::boost::enable_if< ::boost::is_convertible<T,double>, RET >::type
|
Chris@16
|
14 # else
|
Chris@16
|
15 # define BOOST_TR1_MATH_RETURN(RET) RET
|
Chris@16
|
16 # endif
|
Chris@16
|
17
|
Chris@16
|
18 # include <boost/type_traits/is_floating_point.hpp>
|
Chris@16
|
19 # include <boost/type_traits/is_same.hpp>
|
Chris@16
|
20 # include <boost/mpl/if.hpp>
|
Chris@16
|
21
|
Chris@16
|
22 namespace boost{ namespace tr1_detail{
|
Chris@16
|
23
|
Chris@16
|
24 template <class T, class U>
|
Chris@16
|
25 struct largest_real
|
Chris@16
|
26 {
|
Chris@16
|
27 typedef typename boost::mpl::if_<
|
Chris@16
|
28 boost::is_same<long double, T>,
|
Chris@16
|
29 long double,
|
Chris@16
|
30 typename boost::mpl::if_<
|
Chris@16
|
31 boost::is_same<long double, U>,
|
Chris@16
|
32 long double,
|
Chris@16
|
33 typename boost::mpl::if_<
|
Chris@16
|
34 boost::is_same<double, T>,
|
Chris@16
|
35 double,
|
Chris@16
|
36 typename boost::mpl::if_<
|
Chris@16
|
37 boost::is_same<double, U>,
|
Chris@16
|
38 double,
|
Chris@16
|
39 float
|
Chris@16
|
40 >::type
|
Chris@16
|
41 >::type
|
Chris@16
|
42 >::type
|
Chris@16
|
43 >::type type;
|
Chris@16
|
44 };
|
Chris@16
|
45
|
Chris@16
|
46 template <class T, class U>
|
Chris@16
|
47 struct promote_to_real
|
Chris@16
|
48 {
|
Chris@16
|
49 typedef typename largest_real<
|
Chris@16
|
50 typename boost::mpl::if_< boost::is_floating_point<T>, T, double>::type,
|
Chris@16
|
51 typename boost::mpl::if_< boost::is_floating_point<U>, U, double>::type
|
Chris@16
|
52 >::type type;
|
Chris@16
|
53 };
|
Chris@16
|
54
|
Chris@16
|
55 } }
|
Chris@16
|
56
|
Chris@16
|
57 #endif
|
Chris@16
|
58
|