blob: 1e90ee9b6a4c48c7b32e54beb6a56b0643ed7b47 [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_SIGN_MIXTURE_FLC_12NOV2002_HPP
11#define NDNBOOST_NUMERIC_CONVERSION_DETAIL_SIGN_MIXTURE_FLC_12NOV2002_HPP
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070012
13#include "ndnboost/config.hpp"
14#include "ndnboost/limits.hpp"
15
16#include "ndnboost/numeric/conversion/sign_mixture_enum.hpp"
17#include "ndnboost/numeric/conversion/detail/meta.hpp"
18
19#include "ndnboost/mpl/integral_c.hpp"
20
21namespace ndnboost { namespace numeric { namespace convdetail
22{
23 // Integral Constants for 'SignMixture'
24 typedef mpl::integral_c<sign_mixture_enum, unsigned_to_unsigned> unsig2unsig_c ;
25 typedef mpl::integral_c<sign_mixture_enum, signed_to_signed> sig2sig_c ;
26 typedef mpl::integral_c<sign_mixture_enum, signed_to_unsigned> sig2unsig_c ;
27 typedef mpl::integral_c<sign_mixture_enum, unsigned_to_signed> unsig2sig_c ;
28
29 // Metafunction:
30 //
31 // get_sign_mixture<T,S>::type
32 //
33 // Selects the appropriate SignMixture Integral Constant for the combination T,S.
34 //
35 template<class T,class S>
36 struct get_sign_mixture
37 {
38 typedef mpl::bool_< ::std::numeric_limits<S>::is_signed > S_signed ;
39 typedef mpl::bool_< ::std::numeric_limits<T>::is_signed > T_signed ;
40
41 typedef typename
42 for_both<S_signed, T_signed, sig2sig_c, sig2unsig_c, unsig2sig_c, unsig2unsig_c>::type
43 type ;
44 } ;
45
46 // Metafunction:
47 //
48 // for_sign_mixture<SignMixture,Sig2Sig,Sig2Unsig,Unsig2Sig,Unsig2Unsig>::type
49 //
50 // {SignMixture} is one of the Integral Constants for SignMixture, declared above.
51 // {Sig2Sig,Sig2Unsig,Unsig2Sig,Unsig2Unsig} are aribtrary types. (not metafunctions)
52 //
53 // According to the value of 'SignMixture', selects the corresponding type.
54 //
55 template<class SignMixture, class Sig2Sig, class Sig2Unsig, class Unsig2Sig, class Unsig2Unsig>
56 struct for_sign_mixture
57 {
58 typedef typename
59 ct_switch4<SignMixture
60 , sig2sig_c, sig2unsig_c, unsig2sig_c // default
61 , Sig2Sig , Sig2Unsig , Unsig2Sig , Unsig2Unsig
62 >::type
63 type ;
64 } ;
65
66} } } // namespace ndnboost::numeric::convdetail
67
68#endif
69//
70///////////////////////////////////////////////////////////////////////////////////////////////
71
72