value_type.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Boost.Range library
  2. //
  3. // Copyright Thorsten Ottosen 2003-2004. Use, modification and
  4. // distribution is subject to the Boost Software License, Version
  5. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // For more information, see http://www.boost.org/libs/range/
  9. //
  10. #ifndef BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
  11. #define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
  12. #include <boost/range/detail/common.hpp>
  13. #include <boost/range/detail/remove_extent.hpp>
  14. #include <boost/iterator/iterator_traits.hpp>
  15. //////////////////////////////////////////////////////////////////////////////
  16. // missing partial specialization workaround.
  17. //////////////////////////////////////////////////////////////////////////////
  18. namespace boost
  19. {
  20. namespace range_detail
  21. {
  22. template< typename T >
  23. struct range_value_type_;
  24. template<>
  25. struct range_value_type_<std_container_>
  26. {
  27. template< typename C >
  28. struct pts
  29. {
  30. typedef BOOST_RANGE_DEDUCED_TYPENAME C::value_type type;
  31. };
  32. };
  33. template<>
  34. struct range_value_type_<std_pair_>
  35. {
  36. template< typename P >
  37. struct pts
  38. {
  39. typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_value< BOOST_RANGE_DEDUCED_TYPENAME P::first_type >::type type;
  40. };
  41. };
  42. template<>
  43. struct range_value_type_<array_>
  44. {
  45. template< typename T >
  46. struct pts
  47. {
  48. typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type type;
  49. };
  50. };
  51. }
  52. template< typename C >
  53. class range_value
  54. {
  55. typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
  56. public:
  57. typedef BOOST_DEDUCED_TYPENAME range_detail::range_value_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
  58. };
  59. }
  60. #endif