Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | // Copyright 2005 Alexander Nasonov. |
| 2 | // Distributed under the Boost Software License, Version 1.0. (See |
| 3 | // accompanying file LICENSE_1_0.txt or copy at |
| 4 | // http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | #ifndef FILE_boost_type_traits_floating_point_promotion_hpp_INCLUDED |
| 7 | #define FILE_boost_type_traits_floating_point_promotion_hpp_INCLUDED |
| 8 | |
| 9 | #include <ndnboost/config.hpp> |
| 10 | |
| 11 | #ifdef BOOST_NO_CV_SPECIALIZATIONS |
| 12 | #include <ndnboost/mpl/at.hpp> |
| 13 | #include <ndnboost/mpl/int.hpp> |
| 14 | #include <ndnboost/mpl/multiplies.hpp> |
| 15 | #include <ndnboost/mpl/plus.hpp> |
| 16 | #include <ndnboost/mpl/vector.hpp> |
| 17 | #include <ndnboost/type_traits/is_same.hpp> |
| 18 | #endif |
| 19 | |
| 20 | // Should be the last #include |
| 21 | #include <ndnboost/type_traits/detail/type_trait_def.hpp> |
| 22 | |
| 23 | namespace ndnboost { |
| 24 | |
| 25 | namespace type_traits { namespace detail { |
| 26 | |
| 27 | #ifndef BOOST_NO_CV_SPECIALIZATIONS |
| 28 | |
| 29 | template<class T> |
| 30 | struct floating_point_promotion |
| 31 | { |
| 32 | typedef T type; |
| 33 | }; |
| 34 | |
| 35 | template<> |
| 36 | struct floating_point_promotion<float> |
| 37 | { |
| 38 | typedef double type; |
| 39 | }; |
| 40 | |
| 41 | template<> |
| 42 | struct floating_point_promotion<float const> |
| 43 | { |
| 44 | typedef double const type; |
| 45 | }; |
| 46 | |
| 47 | template<> |
| 48 | struct floating_point_promotion<float volatile> |
| 49 | { |
| 50 | typedef double volatile type; |
| 51 | }; |
| 52 | |
| 53 | template<> |
| 54 | struct floating_point_promotion<float const volatile> |
| 55 | { |
| 56 | typedef double const volatile type; |
| 57 | }; |
| 58 | |
| 59 | #else |
| 60 | |
| 61 | template<class T> |
| 62 | struct floating_point_promotion |
| 63 | : mpl::at< |
| 64 | mpl::vector< T, double, double const, double volatile, |
| 65 | double const volatile > |
| 66 | , mpl::plus< |
| 67 | is_same<T, float> |
| 68 | , mpl::multiplies< is_same<T, float const> , mpl::int_<2> > |
| 69 | , mpl::multiplies< is_same<T, float volatile> , mpl::int_<3> > |
| 70 | , mpl::multiplies< is_same<T, float const volatile>, mpl::int_<4> > |
| 71 | > |
| 72 | > |
| 73 | { |
| 74 | }; |
| 75 | |
| 76 | #endif |
| 77 | |
| 78 | } } |
| 79 | |
| 80 | BOOST_TT_AUX_TYPE_TRAIT_DEF1( |
| 81 | floating_point_promotion |
| 82 | , T |
| 83 | , BOOST_DEDUCED_TYPENAME |
| 84 | ndnboost::type_traits::detail::floating_point_promotion<T>::type |
| 85 | ) |
| 86 | } |
| 87 | |
| 88 | #include <ndnboost/type_traits/detail/type_trait_undef.hpp> |
| 89 | |
| 90 | #endif // #ifndef FILE_boost_type_traits_floating_point_promotion_hpp_INCLUDED |
| 91 | |