domain_type_of.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_DOMAIN_TYPE_OF_HPP_JOFA_100902
  9. #define BOOST_ICL_TYPE_TRAITS_DOMAIN_TYPE_OF_HPP_JOFA_100902
  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(domain_type)
  18. }
  19. template <class Type>
  20. struct has_domain_type
  21. : mpl::bool_<detail::has_domain_type<Type>::value>
  22. {};
  23. template <class Type, bool has_domain_type>
  24. struct get_domain_type;
  25. template <class Type>
  26. struct get_domain_type<Type, false>
  27. {
  28. typedef no_type type;
  29. };
  30. template <class Type>
  31. struct get_domain_type<Type, true>
  32. {
  33. typedef typename Type::domain_type type;
  34. };
  35. template <class Type>
  36. struct domain_type_of
  37. {
  38. typedef typename
  39. get_domain_type<Type, has_domain_type<Type>::value>::type type;
  40. };
  41. }} // namespace boost icl
  42. #endif