blob: b774da1e0179a066090de4e85f6995c79a6b1d48 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// 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
Jeff Thompson2491bd62013-10-15 17:10:24 -07006#ifndef FILE_ndnboost_type_traits_floating_point_promotion_hpp_INCLUDED
7#define FILE_ndnboost_type_traits_floating_point_promotion_hpp_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07008
9#include <ndnboost/config.hpp>
10
Jeff Thompson3d613fd2013-10-15 15:39:04 -070011#ifdef NDNBOOST_NO_CV_SPECIALIZATIONS
Jeff Thompsona28eed82013-08-22 16:21:10 -070012#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
23namespace ndnboost {
24
25namespace type_traits { namespace detail {
26
Jeff Thompson3d613fd2013-10-15 15:39:04 -070027#ifndef NDNBOOST_NO_CV_SPECIALIZATIONS
Jeff Thompsona28eed82013-08-22 16:21:10 -070028
29template<class T>
30struct floating_point_promotion
31{
32 typedef T type;
33};
34
35template<>
36struct floating_point_promotion<float>
37{
38 typedef double type;
39};
40
41template<>
42struct floating_point_promotion<float const>
43{
44 typedef double const type;
45};
46
47template<>
48struct floating_point_promotion<float volatile>
49{
50 typedef double volatile type;
51};
52
53template<>
54struct floating_point_promotion<float const volatile>
55{
56 typedef double const volatile type;
57};
58
59#else
60
61template<class T>
62struct 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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080NDNBOOST_TT_AUX_TYPE_TRAIT_DEF1(
Jeff Thompsona28eed82013-08-22 16:21:10 -070081 floating_point_promotion
82 , T
Jeff Thompson3d613fd2013-10-15 15:39:04 -070083 , NDNBOOST_DEDUCED_TYPENAME
Jeff Thompsona28eed82013-08-22 16:21:10 -070084 ndnboost::type_traits::detail::floating_point_promotion<T>::type
85 )
86}
87
88#include <ndnboost/type_traits/detail/type_trait_undef.hpp>
89
Jeff Thompson2491bd62013-10-15 17:10:24 -070090#endif // #ifndef FILE_ndnboost_type_traits_floating_point_promotion_hpp_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070091