File indexing completed on 2025-01-18 09:51:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef BOOST_RANDOM_TRAITS_HPP
0020 #define BOOST_RANDOM_TRAITS_HPP
0021
0022 #include <boost/type_traits/integral_constant.hpp>
0023 #include <boost/type_traits/is_signed.hpp>
0024 #include <boost/type_traits/is_integral.hpp>
0025 #include <boost/type_traits/make_unsigned.hpp>
0026 #include <limits>
0027
0028 namespace boost {
0029 namespace random {
0030 namespace traits {
0031
0032 template <class T, bool intrinsic>
0033 struct make_unsigned_imp
0034 {
0035 typedef typename boost::make_unsigned<T>::type type;
0036 };
0037 template <class T>
0038 struct make_unsigned_imp<T, false>
0039 {
0040 BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
0041 BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_signed == false);
0042 BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_integer == true);
0043 typedef T type;
0044 };
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 template <class T>
0056 struct make_unsigned
0057
0058 : public make_unsigned_imp < T, boost::is_integral<T>::value >
0059
0060 {};
0061
0062 template <class T, bool intrinsic>
0063 struct make_unsigned_or_unbounded_imp
0064 {
0065 typedef typename boost::make_unsigned<T>::type type;
0066 };
0067 template <class T>
0068 struct make_unsigned_or_unbounded_imp<T, false>
0069 {
0070 BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
0071 BOOST_STATIC_ASSERT((std::numeric_limits<T>::is_signed == false) || (std::numeric_limits<T>::is_bounded == false));
0072 BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_integer == true);
0073 typedef T type;
0074 };
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 template <class T>
0086 struct make_unsigned_or_unbounded
0087
0088 : public make_unsigned_or_unbounded_imp < T, boost::is_integral<T>::value >
0089
0090 {};
0091
0092
0093 template <class T>
0094 struct is_integral
0095 : public integral_constant<bool, boost::is_integral<T>::value || (std::numeric_limits<T>::is_integer)>
0096 {};
0097
0098
0099 template <class T> struct is_signed
0100 : public integral_constant<bool, boost::is_signed<T>::value || (std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_signed)>
0101 {};
0102
0103 }
0104 }
0105 }
0106
0107 #endif