williamr@2
|
1 |
// © Copyright Fernando Luis Cacciola Carballal 2000-2004
|
williamr@2
|
2 |
// Use, modification, and distribution is subject to the Boost Software
|
williamr@2
|
3 |
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
williamr@2
|
4 |
// http://www.boost.org/LICENSE_1_0.txt)
|
williamr@2
|
5 |
|
williamr@2
|
6 |
// See library home page at http://www.boost.org/libs/numeric/conversion
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Contact the author at: fernando_cacciola@hotmail.com
|
williamr@2
|
9 |
//
|
williamr@2
|
10 |
#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP
|
williamr@2
|
11 |
#define BOOST_NUMERIC_CONVERSION_DETAIL_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP
|
williamr@2
|
12 |
|
williamr@2
|
13 |
#include "boost/config.hpp"
|
williamr@2
|
14 |
#include "boost/limits.hpp"
|
williamr@2
|
15 |
|
williamr@2
|
16 |
#include "boost/numeric/conversion/int_float_mixture_enum.hpp"
|
williamr@2
|
17 |
#include "boost/numeric/conversion/detail/meta.hpp"
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#include "boost/mpl/integral_c.hpp"
|
williamr@2
|
20 |
|
williamr@2
|
21 |
namespace boost { namespace numeric { namespace convdetail
|
williamr@2
|
22 |
{
|
williamr@2
|
23 |
// Integral Constants for 'IntFloatMixture'
|
williamr@2
|
24 |
typedef mpl::integral_c<int_float_mixture_enum, integral_to_integral> int2int_c ;
|
williamr@2
|
25 |
typedef mpl::integral_c<int_float_mixture_enum, integral_to_float> int2float_c ;
|
williamr@2
|
26 |
typedef mpl::integral_c<int_float_mixture_enum, float_to_integral> float2int_c ;
|
williamr@2
|
27 |
typedef mpl::integral_c<int_float_mixture_enum, float_to_float> float2float_c ;
|
williamr@2
|
28 |
|
williamr@2
|
29 |
// Metafunction:
|
williamr@2
|
30 |
//
|
williamr@2
|
31 |
// get_int_float_mixture<T,S>::type
|
williamr@2
|
32 |
//
|
williamr@2
|
33 |
// Selects the appropriate Int-Float Mixture Integral Constant for the combination T,S.
|
williamr@2
|
34 |
//
|
williamr@2
|
35 |
template<class T,class S>
|
williamr@2
|
36 |
struct get_int_float_mixture
|
williamr@2
|
37 |
{
|
williamr@2
|
38 |
typedef mpl::bool_< ::std::numeric_limits<S>::is_integer > S_int ;
|
williamr@2
|
39 |
typedef mpl::bool_< ::std::numeric_limits<T>::is_integer > T_int ;
|
williamr@2
|
40 |
|
williamr@2
|
41 |
typedef typename
|
williamr@2
|
42 |
for_both<S_int, T_int, int2int_c, int2float_c, float2int_c, float2float_c>::type
|
williamr@2
|
43 |
type ;
|
williamr@2
|
44 |
} ;
|
williamr@2
|
45 |
|
williamr@2
|
46 |
// Metafunction:
|
williamr@2
|
47 |
//
|
williamr@2
|
48 |
// for_int_float_mixture<Mixture,int_int,int_float,float_int,float_float>::type
|
williamr@2
|
49 |
//
|
williamr@2
|
50 |
// {Mixture} is one of the Integral Constants for Mixture, declared above.
|
williamr@2
|
51 |
// {int_int,int_float,float_int,float_float} are aribtrary types. (not metafunctions)
|
williamr@2
|
52 |
//
|
williamr@2
|
53 |
// According to the value of 'IntFloatMixture', selects the corresponding type.
|
williamr@2
|
54 |
//
|
williamr@2
|
55 |
template<class IntFloatMixture, class Int2Int, class Int2Float, class Float2Int, class Float2Float>
|
williamr@2
|
56 |
struct for_int_float_mixture
|
williamr@2
|
57 |
{
|
williamr@2
|
58 |
typedef typename
|
williamr@2
|
59 |
ct_switch4<IntFloatMixture
|
williamr@2
|
60 |
,int2int_c, int2float_c, float2int_c // default
|
williamr@2
|
61 |
,Int2Int , Int2Float , Float2Int , Float2Float
|
williamr@2
|
62 |
>::type
|
williamr@2
|
63 |
type ;
|
williamr@2
|
64 |
} ;
|
williamr@2
|
65 |
|
williamr@2
|
66 |
} } } // namespace boost::numeric::convdetail
|
williamr@2
|
67 |
|
williamr@2
|
68 |
#endif
|
williamr@2
|
69 |
//
|
williamr@2
|
70 |
///////////////////////////////////////////////////////////////////////////////////////////////
|
williamr@2
|
71 |
|
williamr@2
|
72 |
|