meta.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Boost.Geometry Index
  2. //
  3. // Copyright (c) 2011-2019 Adam Wulkiewicz, Lodz, Poland.
  4. //
  5. // This file was modified by Oracle on 2020.
  6. // Modifications copyright (c) 2020 Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. //
  9. // Use, modification and distribution is subject to the Boost Software License,
  10. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  11. // http://www.boost.org/LICENSE_1_0.txt)
  12. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_META_HPP
  13. #define BOOST_GEOMETRY_INDEX_DETAIL_META_HPP
  14. #include <type_traits>
  15. //#include <boost/range/value_type.hpp>
  16. namespace boost { namespace geometry { namespace index { namespace detail {
  17. //template <typename T, typename V, bool IsRange = range::detail::is_range<T>::value>
  18. //struct is_range_of_convertible_values_impl
  19. // : std::is_convertible<typename ::boost::range_value<T>::type, V>
  20. //{};
  21. //
  22. //template <typename T, typename V>
  23. //struct is_range_of_convertible_values_impl<T, V, false>
  24. // : std::integral_constant<bool, false>
  25. //{};
  26. //
  27. //template <typename T, typename V>
  28. //struct is_range_of_convertible_values
  29. // : is_range_of_convertible_values_impl<T, V>
  30. //{};
  31. // Implemented this way in order to prevent instantiation of all type traits at
  32. // once because some of them are causing problems with gcc 4.6 namely
  33. // is_convertible<bg::model::segment<>, std::pair<bg::model::segment<>, T> >
  34. // because segment<> is derived from pair<> and pair<> has copy ctor taking
  35. // other pair<> of any types the compiler tries to instantiate ctor of
  36. // pair<segment, T> taking pair<point, point> which results in instantiation of
  37. // segment's ctor taking a point which results in compilation error.
  38. // This is probably compiler's bug.
  39. template <typename T, typename Value, typename Indexable, typename ResultType, int Ver>
  40. struct convertible_type_impl
  41. {
  42. typedef ResultType type;
  43. };
  44. template <typename T, typename Value, typename Indexable>
  45. struct convertible_type_impl<T, Value, Indexable, void, 0>
  46. {
  47. typedef std::conditional_t
  48. <
  49. std::is_convertible<T, Indexable>::value,
  50. Indexable,
  51. void
  52. > result_type;
  53. typedef typename convertible_type_impl
  54. <
  55. T, Value, Indexable, result_type, 1
  56. >::type type;
  57. };
  58. template <typename T, typename Value, typename Indexable>
  59. struct convertible_type_impl<T, Value, Indexable, void, 1>
  60. {
  61. typedef std::conditional_t
  62. <
  63. std::is_convertible<T, Value>::value,
  64. Value,
  65. void
  66. > type;
  67. };
  68. template <typename T, typename Value, typename Indexable>
  69. struct convertible_type
  70. {
  71. typedef std::conditional_t
  72. <
  73. std::is_same<T, Value>::value,
  74. Value,
  75. std::conditional_t
  76. <
  77. std::is_same<T, Indexable>::value,
  78. Indexable,
  79. void
  80. >
  81. > result_type;
  82. typedef typename convertible_type_impl
  83. <
  84. T, Value, Indexable, result_type, 0
  85. >::type type;
  86. };
  87. }}}} // namespace boost::geometry::index::detail
  88. #endif // BOOST_GEOMETRY_INDEX_DETAIL_META_HPP