]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/index/detail/meta.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / index / detail / meta.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry Index
2//
92f5a8d4 3// Copyright (c) 2011-2019 Adam Wulkiewicz, Lodz, Poland.
7c673cae
FG
4//
5// Use, modification and distribution is subject to the Boost Software License,
6// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9#include <boost/range.hpp>
10#include <boost/mpl/aux_/has_type.hpp>
11#include <boost/mpl/if.hpp>
12#include <boost/mpl/and.hpp>
92f5a8d4
TL
13#include <boost/type_traits/is_convertible.hpp>
14#include <boost/type_traits/is_same.hpp>
7c673cae
FG
15
16#ifndef BOOST_GEOMETRY_INDEX_DETAIL_META_HPP
17#define BOOST_GEOMETRY_INDEX_DETAIL_META_HPP
18
19namespace boost { namespace geometry { namespace index { namespace detail {
20
21template <typename T>
22struct is_range
23 : ::boost::mpl::aux::has_type< ::boost::range_iterator<T> >
24{};
25
26//template <typename T, typename V, bool IsRange>
27//struct is_range_of_convertible_values_impl
28// : ::boost::is_convertible<typename ::boost::range_value<T>::type, V>
29//{};
30//
31//template <typename T, typename V>
32//struct is_range_of_convertible_values_impl<T, V, false>
33// : ::boost::mpl::bool_<false>
34//{};
35//
36//template <typename T, typename V>
37//struct is_range_of_convertible_values
38// : is_range_of_convertible_values_impl<T, V, is_range<T>::value>
39//{};
40
92f5a8d4
TL
41// Implemented this way in order to prevent instantiation of all type traits at
42// once because some of them are causing problems with gcc 4.6 namely
43// is_convertible<bg::model::segment<>, std::pair<bg::model::segment<>, T> >
44// because segment<> is derived from pair<> and pair<> has copy ctor taking
45// other pair<> of any types the compiler tries to instantiate ctor of
46// pair<segment, T> taking pair<point, point> which results in instantiation of
47// segment's ctor taking a point which results in compilation error.
48// This is probably compiler's bug.
49template <typename T, typename Value, typename Indexable, typename ResultType, int Ver>
50struct convertible_type_impl
51{
52 typedef ResultType type;
53};
54
55template <typename T, typename Value, typename Indexable>
56struct convertible_type_impl<T, Value, Indexable, void, 0>
57{
58 typedef typename boost::mpl::if_c
59 <
60 boost::is_convertible<T, Indexable>::value,
61 Indexable,
62 void
63 >::type result_type;
64
65 typedef typename convertible_type_impl
66 <
67 T, Value, Indexable, result_type, 1
68 >::type type;
69};
70
71template <typename T, typename Value, typename Indexable>
72struct convertible_type_impl<T, Value, Indexable, void, 1>
73{
74 typedef typename boost::mpl::if_c
75 <
76 boost::is_convertible<T, Value>::value,
77 Value,
78 void
79 >::type type;
80};
81
82template <typename T, typename Value, typename Indexable>
83struct convertible_type
84{
85 typedef typename boost::mpl::if_c
86 <
87 boost::is_same<T, Value>::value,
88 Value,
89 typename boost::mpl::if_c
90 <
91 boost::is_same<T, Indexable>::value,
92 Indexable,
93 void
94 >::type
95 >::type result_type;
96
97 typedef typename convertible_type_impl
98 <
99 T, Value, Indexable, result_type, 0
100 >::type type;
101};
102
7c673cae
FG
103}}}} // namespace boost::geometry::index::detail
104
105#endif // BOOST_GEOMETRY_INDEX_DETAIL_META_HPP