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