is_discrete.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2008-2009: Joachim Faulhaber
  3. +------------------------------------------------------------------------------+
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENCE.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. +-----------------------------------------------------------------------------*/
  8. #ifndef BOOST_ICL_TYPE_TRAITS_IS_DISCRETE_HPP_JOFA_100410
  9. #define BOOST_ICL_TYPE_TRAITS_IS_DISCRETE_HPP_JOFA_100410
  10. #include <string>
  11. #include <boost/config.hpp> // For macro BOOST_STATIC_CONSTANT
  12. #include <boost/mpl/and.hpp>
  13. #include <boost/mpl/not.hpp>
  14. #ifdef BOOST_MSVC
  15. #pragma warning(push)
  16. #pragma warning(disable:4913) // user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used
  17. #endif
  18. #include <boost/detail/is_incrementable.hpp>
  19. #ifdef BOOST_MSVC
  20. #pragma warning(pop)
  21. #endif
  22. #include <boost/type_traits/is_integral.hpp>
  23. #include <boost/type_traits/is_floating_point.hpp>
  24. #include <boost/icl/type_traits/rep_type_of.hpp>
  25. #include <boost/icl/type_traits/is_numeric.hpp>
  26. namespace boost{ namespace icl
  27. {
  28. template <class Type> struct is_discrete
  29. {
  30. typedef is_discrete type;
  31. BOOST_STATIC_CONSTANT(bool,
  32. value =
  33. (mpl::and_
  34. <
  35. boost::detail::is_incrementable<Type>
  36. , mpl::or_
  37. <
  38. mpl::and_
  39. <
  40. mpl::not_<has_rep_type<Type> >
  41. , is_non_floating_point<Type>
  42. >
  43. , mpl::and_
  44. <
  45. has_rep_type<Type>
  46. , is_discrete<typename rep_type_of<Type>::type>
  47. >
  48. >
  49. >::value
  50. )
  51. );
  52. };
  53. }} // namespace boost icl
  54. #endif