interval_type_of.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2010-2010: 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_INTERVAL_TYPE_OF_HPP_JOFA_100910
  9. #define BOOST_ICL_TYPE_TRAITS_INTERVAL_TYPE_OF_HPP_JOFA_100910
  10. #include <boost/mpl/has_xxx.hpp>
  11. #include <boost/mpl/bool.hpp>
  12. #include <boost/icl/type_traits/no_type.hpp>
  13. namespace boost{ namespace icl
  14. {
  15. namespace detail
  16. {
  17. BOOST_MPL_HAS_XXX_TRAIT_DEF(interval_type)
  18. }
  19. template <class Type>
  20. struct has_interval_type
  21. : mpl::bool_<detail::has_interval_type<Type>::value>
  22. {};
  23. template <class Type, bool has_interval_type>
  24. struct get_interval_type;
  25. template <class Type>
  26. struct get_interval_type<Type, false>
  27. {
  28. typedef no_type type;
  29. };
  30. template <class Type>
  31. struct get_interval_type<Type, true>
  32. {
  33. typedef typename Type::interval_type type;
  34. };
  35. template <class Type>
  36. struct interval_type_of
  37. {
  38. typedef typename
  39. get_interval_type<Type, has_interval_type<Type>::value>::type type;
  40. };
  41. }} // namespace boost icl
  42. #endif