]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/get_max_size.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / get_max_size.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2014 Mateusz Loskot, London, UK.
6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
7
8 // This file was modified by Oracle on 2018.
9 // Modifications copyright (c) 2018, Oracle and/or its affiliates.
10
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12
13 // Use, modification and distribution is subject to the Boost Software License,
14 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16
17 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP
18 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP
19
20 #include <cstddef>
21
22 #include <boost/geometry/core/access.hpp>
23 #include <boost/geometry/core/coordinate_dimension.hpp>
24 #include <boost/geometry/util/math.hpp>
25
26 namespace boost { namespace geometry
27 {
28
29 #ifndef DOXYGEN_NO_DETAIL
30 namespace detail
31 {
32
33 template <typename Box, std::size_t Dimension>
34 struct get_max_size_box
35 {
36 static inline typename coordinate_type<Box>::type apply(Box const& box)
37 {
38 typename coordinate_type<Box>::type s
39 = geometry::math::abs(geometry::get<1, Dimension>(box) - geometry::get<0, Dimension>(box));
40
41 return (std::max)(s, get_max_size_box<Box, Dimension - 1>::apply(box));
42 }
43 };
44
45 template <typename Box>
46 struct get_max_size_box<Box, 0>
47 {
48 static inline typename coordinate_type<Box>::type apply(Box const& box)
49 {
50 return geometry::math::abs(geometry::get<1, 0>(box) - geometry::get<0, 0>(box));
51 }
52 };
53
54 // This might be implemented later on for other geometries too.
55 // Not dispatched yet.
56 template <typename Box>
57 inline typename coordinate_type<Box>::type get_max_size(Box const& box)
58 {
59 return get_max_size_box<Box, dimension<Box>::value - 1>::apply(box);
60 }
61
62 } // namespace detail
63 #endif // DOXYGEN_NO_DETAIL
64
65
66 }} // namespace boost::geometry
67
68
69 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP