codomain_type_of.hpp 1.8 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_CODOMAIN_TYPE_OF_HPP_JOFA_100829
  9. #define BOOST_ICL_TYPE_TRAITS_CODOMAIN_TYPE_OF_HPP_JOFA_100829
  10. #include <set>
  11. #include <boost/mpl/has_xxx.hpp>
  12. #include <boost/mpl/bool.hpp>
  13. #include <boost/icl/type_traits/no_type.hpp>
  14. #include <boost/icl/type_traits/is_container.hpp>
  15. namespace boost{ namespace icl
  16. {
  17. namespace detail
  18. {
  19. BOOST_MPL_HAS_XXX_TRAIT_DEF(codomain_type)
  20. }
  21. template <class Type>
  22. struct has_codomain_type
  23. : mpl::bool_<detail::has_codomain_type<Type>::value>
  24. {};
  25. template <class Type, bool has_codomain_type, bool is_std_set>
  26. struct get_codomain_type;
  27. template <class Type>
  28. struct get_codomain_type<Type, false, false>
  29. {
  30. typedef no_type type;
  31. };
  32. template <class Type, bool is_std_set>
  33. struct get_codomain_type<Type, true, is_std_set>
  34. {
  35. typedef typename Type::codomain_type type;
  36. };
  37. template <class Type>
  38. struct get_codomain_type<Type, false, true>
  39. {
  40. typedef typename Type::value_type type;
  41. };
  42. template <class Type>
  43. struct codomain_type_of
  44. {
  45. typedef typename
  46. get_codomain_type< Type
  47. , has_codomain_type<Type>::value
  48. , is_std_set<Type>::value
  49. >::type type;
  50. };
  51. }} // namespace boost icl
  52. #endif