blob: 33382ec2c8ab37457ee889ea43fc30de8ea5f80d [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004
2// Use, modification, and distribution is subject to the Boost Software
3// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6// See library home page at http://www.boost.org/libs/numeric/conversion
7//
8// Contact the author at: fernando_cacciola@hotmail.com
9//
Jeff Thompson3d613fd2013-10-15 15:39:04 -070010#ifndef NDNBOOST_NUMERIC_CONVERSION_DETAIL_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP
11#define NDNBOOST_NUMERIC_CONVERSION_DETAIL_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070012
13#include "ndnboost/type_traits/is_arithmetic.hpp"
14
15#include "ndnboost/numeric/conversion/udt_builtin_mixture_enum.hpp"
16#include "ndnboost/numeric/conversion/detail/meta.hpp"
17
18#include "ndnboost/mpl/integral_c.hpp"
19
20namespace ndnboost { namespace numeric { namespace convdetail
21{
22 // Integral Constants for 'UdtMixture'
23 typedef mpl::integral_c<udt_builtin_mixture_enum, builtin_to_builtin> builtin2builtin_c ;
24 typedef mpl::integral_c<udt_builtin_mixture_enum, builtin_to_udt> builtin2udt_c ;
25 typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_builtin> udt2builtin_c ;
26 typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_udt> udt2udt_c ;
27
28 // Metafunction:
29 //
30 // for_udt_mixture<UdtMixture,BuiltIn2BuiltIn,BuiltIn2Udt,Udt2BuiltIn,Udt2Udt>::type
31 //
32 // {UdtMixture} is one of the Integral Constants for UdMixture, declared above.
33 // {BuiltIn2BuiltIn,BuiltIn2Udt,Udt2BuiltIn,Udt2Udt} are aribtrary types. (not metafunctions)
34 //
35 // According to the value of 'UdtMixture', selects the corresponding type.
36 //
37 template<class UdtMixture, class BuiltIn2BuiltIn, class BuiltIn2Udt, class Udt2BuiltIn, class Udt2Udt>
38 struct for_udt_builtin_mixture
39 {
40 typedef typename
41 ct_switch4<UdtMixture
42 , builtin2builtin_c, builtin2udt_c, udt2builtin_c // default
43 , BuiltIn2BuiltIn , BuiltIn2Udt , Udt2BuiltIn , Udt2Udt
44 >::type
45 type ;
46 } ;
47
48 // Metafunction:
49 //
50 // get_udt_mixture<T,S>::type
51 //
52 // Selects the appropriate UdtMixture Integral Constant for the combination T,S.
53 //
54 template<class T,class S>
55 struct get_udt_builtin_mixture
56 {
57 typedef is_arithmetic<S> S_builtin ;
58 typedef is_arithmetic<T> T_builtin ;
59
60 typedef typename
61 for_both<S_builtin, T_builtin, builtin2builtin_c, builtin2udt_c, udt2builtin_c, udt2udt_c>::type
62 type ;
63 } ;
64
65} } } // namespace ndnboost::numeric::convdetail
66
67#endif
68
69