123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #ifndef BOOST_RANDOM_TRAITS_HPP
- #define BOOST_RANDOM_TRAITS_HPP
- #include <boost/type_traits/integral_constant.hpp>
- #include <boost/type_traits/is_signed.hpp>
- #include <boost/type_traits/is_integral.hpp>
- #include <boost/type_traits/make_unsigned.hpp>
- #include <limits>
- namespace boost {
- namespace random {
- namespace traits {
-
- template <class T, bool intrinsic>
- struct make_unsigned_imp
- {
- typedef typename boost::make_unsigned<T>::type type;
- };
- template <class T>
- struct make_unsigned_imp<T, false>
- {
- BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
- BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_signed == false);
- BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_integer == true);
- typedef T type;
- };
-
-
- template <class T>
- struct make_unsigned
- // \cond show_private
- : public make_unsigned_imp < T, boost::is_integral<T>::value >
- // \endcond
- {};
-
- template <class T, bool intrinsic>
- struct make_unsigned_or_unbounded_imp
- {
- typedef typename boost::make_unsigned<T>::type type;
- };
- template <class T>
- struct make_unsigned_or_unbounded_imp<T, false>
- {
- BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
- BOOST_STATIC_ASSERT((std::numeric_limits<T>::is_signed == false) || (std::numeric_limits<T>::is_bounded == false));
- BOOST_STATIC_ASSERT(std::numeric_limits<T>::is_integer == true);
- typedef T type;
- };
-
-
- template <class T>
- struct make_unsigned_or_unbounded
- // \cond show_private
- : public make_unsigned_or_unbounded_imp < T, boost::is_integral<T>::value >
- // \endcond
- {};
-
- template <class T>
- struct is_integral
- : public integral_constant<bool, boost::is_integral<T>::value || (std::numeric_limits<T>::is_integer)>
- {};
-
- template <class T> struct is_signed
- : 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)>
- {};
- }
- }
- }
- #endif
|