]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/strategies/compare.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / strategies / compare.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
6
7// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14
15#ifndef BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
16#define BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP
17
18#include <cstddef>
19#include <functional>
20
21#include <boost/mpl/if.hpp>
22
23#include <boost/geometry/core/cs.hpp>
24#include <boost/geometry/core/coordinate_type.hpp>
25
26#include <boost/geometry/strategies/tags.hpp>
27
28
29namespace boost { namespace geometry
30{
31
32
33/*!
34 \brief Traits class binding a comparing strategy to a coordinate system
35 \ingroup util
36 \tparam Tag tag of coordinate system of point-type
37 \tparam Direction direction to compare on: 1 for less (-> ascending order)
38 and -1 for greater (-> descending order)
39 \tparam Point point-type
40 \tparam CoordinateSystem coordinate sytem of point
41 \tparam Dimension: the dimension to compare on
42*/
43template
44<
45 typename Tag,
46 int Direction,
47 typename Point,
48 typename CoordinateSystem,
49 std::size_t Dimension
50>
51struct strategy_compare
52{
53 typedef strategy::not_implemented type;
54};
55
56
57#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
58
59// For compare we add defaults specializations,
60// because they defaultly redirect to std::less / greater / equal_to
61template
62<
63 typename Tag,
64 typename Point,
65 typename CoordinateSystem,
66 std::size_t Dimension
67>
68struct strategy_compare<Tag, 1, Point, CoordinateSystem, Dimension>
69{
70 typedef std::less<typename coordinate_type<Point>::type> type;
71};
72
73
74template
75<
76 typename Tag,
77 typename Point,
78 typename CoordinateSystem,
79 std::size_t Dimension
80>
81struct strategy_compare<Tag, -1, Point, CoordinateSystem, Dimension>
82{
83 typedef std::greater<typename coordinate_type<Point>::type> type;
84};
85
86
87template
88<
89 typename Tag,
90 typename Point,
91 typename CoordinateSystem,
92 std::size_t Dimension
93>
94struct strategy_compare<Tag, 0, Point, CoordinateSystem, Dimension>
95{
96 typedef std::equal_to<typename coordinate_type<Point>::type> type;
97};
98
99
100#endif
101
102
103namespace strategy { namespace compare
104{
105
106
107/*!
108 \brief Default strategy, indicates the default strategy for comparisons
109 \details The default strategy for comparisons defer in most cases
110 to std::less (for ascending) and std::greater (for descending).
111 However, if a spherical coordinate system is used, and comparison
112 is done on longitude, it will take another strategy handling circular
113*/
114struct default_strategy {};
115
116
117#ifndef DOXYGEN_NO_DETAIL
118namespace detail
119{
120
121template <typename Type>
122struct is_default : boost::false_type
123{};
124
125
126template <>
127struct is_default<default_strategy> : boost::true_type
128{};
129
130
131/*!
132 \brief Meta-function to select strategy
133 \details If "default_strategy" is specified, it will take the
134 traits-registered class for the specified coordinate system.
135 If another strategy is explicitly specified, it takes that one.
136*/
137template
138<
139 typename Strategy,
140 int Direction,
141 typename Point,
142 std::size_t Dimension
143>
144struct select_strategy
145{
146 typedef typename
147 boost::mpl::if_
148 <
149 is_default<Strategy>,
150 typename strategy_compare
151 <
152 typename cs_tag<Point>::type,
153 Direction,
154 Point,
155 typename coordinate_system<Point>::type,
156 Dimension
157 >::type,
158 Strategy
159 >::type type;
160};
161
162} // namespace detail
163#endif // DOXYGEN_NO_DETAIL
164
165
166}} // namespace strategy::compare
167
168
169}} // namespace boost::geometry
170
171
172#endif // BOOST_GEOMETRY_STRATEGIES_COMPARE_HPP