]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry Index |
2 | // | |
92f5a8d4 | 3 | // Copyright (c) 2011-2019 Adam Wulkiewicz, Lodz, Poland. |
7c673cae | 4 | // |
20effc67 TL |
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 | // | |
7c673cae FG |
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 | ||
7c673cae FG |
13 | #ifndef BOOST_GEOMETRY_INDEX_DETAIL_META_HPP |
14 | #define BOOST_GEOMETRY_INDEX_DETAIL_META_HPP | |
15 | ||
20effc67 | 16 | #include <type_traits> |
7c673cae | 17 | |
20effc67 | 18 | //#include <boost/range/value_type.hpp> |
7c673cae | 19 | |
20effc67 TL |
20 | namespace boost { namespace geometry { namespace index { namespace detail { |
21 | ||
22 | //template <typename T, typename V, bool IsRange = range::detail::is_range<T>::value> | |
7c673cae | 23 | //struct is_range_of_convertible_values_impl |
20effc67 | 24 | // : std::is_convertible<typename ::boost::range_value<T>::type, V> |
7c673cae FG |
25 | //{}; |
26 | // | |
27 | //template <typename T, typename V> | |
28 | //struct is_range_of_convertible_values_impl<T, V, false> | |
20effc67 | 29 | // : std::integral_constant<bool, false> |
7c673cae FG |
30 | //{}; |
31 | // | |
32 | //template <typename T, typename V> | |
33 | //struct is_range_of_convertible_values | |
20effc67 | 34 | // : is_range_of_convertible_values_impl<T, V> |
7c673cae FG |
35 | //{}; |
36 | ||
92f5a8d4 TL |
37 | // Implemented this way in order to prevent instantiation of all type traits at |
38 | // once because some of them are causing problems with gcc 4.6 namely | |
39 | // is_convertible<bg::model::segment<>, std::pair<bg::model::segment<>, T> > | |
40 | // because segment<> is derived from pair<> and pair<> has copy ctor taking | |
41 | // other pair<> of any types the compiler tries to instantiate ctor of | |
42 | // pair<segment, T> taking pair<point, point> which results in instantiation of | |
43 | // segment's ctor taking a point which results in compilation error. | |
44 | // This is probably compiler's bug. | |
45 | template <typename T, typename Value, typename Indexable, typename ResultType, int Ver> | |
46 | struct convertible_type_impl | |
47 | { | |
48 | typedef ResultType type; | |
49 | }; | |
50 | ||
51 | template <typename T, typename Value, typename Indexable> | |
52 | struct convertible_type_impl<T, Value, Indexable, void, 0> | |
53 | { | |
20effc67 | 54 | typedef std::conditional_t |
92f5a8d4 | 55 | < |
20effc67 | 56 | std::is_convertible<T, Indexable>::value, |
92f5a8d4 TL |
57 | Indexable, |
58 | void | |
20effc67 | 59 | > result_type; |
92f5a8d4 TL |
60 | |
61 | typedef typename convertible_type_impl | |
62 | < | |
63 | T, Value, Indexable, result_type, 1 | |
64 | >::type type; | |
65 | }; | |
66 | ||
67 | template <typename T, typename Value, typename Indexable> | |
68 | struct convertible_type_impl<T, Value, Indexable, void, 1> | |
69 | { | |
20effc67 | 70 | typedef std::conditional_t |
92f5a8d4 | 71 | < |
20effc67 | 72 | std::is_convertible<T, Value>::value, |
92f5a8d4 TL |
73 | Value, |
74 | void | |
20effc67 | 75 | > type; |
92f5a8d4 TL |
76 | }; |
77 | ||
78 | template <typename T, typename Value, typename Indexable> | |
79 | struct convertible_type | |
80 | { | |
20effc67 | 81 | typedef std::conditional_t |
92f5a8d4 | 82 | < |
20effc67 | 83 | std::is_same<T, Value>::value, |
92f5a8d4 | 84 | Value, |
20effc67 | 85 | std::conditional_t |
92f5a8d4 | 86 | < |
20effc67 | 87 | std::is_same<T, Indexable>::value, |
92f5a8d4 TL |
88 | Indexable, |
89 | void | |
20effc67 TL |
90 | > |
91 | > result_type; | |
92f5a8d4 TL |
92 | |
93 | typedef typename convertible_type_impl | |
94 | < | |
95 | T, Value, Indexable, result_type, 0 | |
96 | >::type type; | |
97 | }; | |
98 | ||
7c673cae FG |
99 | }}}} // namespace boost::geometry::index::detail |
100 | ||
101 | #endif // BOOST_GEOMETRY_INDEX_DETAIL_META_HPP |