source: NonGTP/Boost/boost/numeric/conversion/detail/sign_mixture.hpp @ 857

Revision 857, 2.6 KB checked in by igarcia, 19 years ago (diff)
Line 
1//  © 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//
10#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_SIGN_MIXTURE_FLC_12NOV2002_HPP
11#define BOOST_NUMERIC_CONVERSION_DETAIL_SIGN_MIXTURE_FLC_12NOV2002_HPP
12
13#include "boost/config.hpp"
14#include "boost/limits.hpp"
15
16#include "boost/numeric/conversion/sign_mixture_enum.hpp"
17#include "boost/numeric/conversion/detail/meta.hpp"
18
19#include "boost/mpl/integral_c.hpp"
20
21namespace boost { 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 boost::numeric::convdetail
67
68#endif
69//
70///////////////////////////////////////////////////////////////////////////////////////////////
71
72
Note: See TracBrowser for help on using the repository browser.