]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/single_geometry.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / single_geometry.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4
5// This file was modified by Oracle on 2013, 2014.
6// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates.
7
8// Use, modification and distribution is subject to the Boost Software License,
9// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10// http://www.boost.org/LICENSE_1_0.txt)
11
12// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13
14#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
15#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP
16
17#include <boost/mpl/if.hpp>
18#include <boost/type_traits/is_base_of.hpp>
19
20#include <boost/geometry/core/assert.hpp>
21#include <boost/geometry/core/tag.hpp>
22#include <boost/geometry/util/range.hpp>
23
24namespace boost { namespace geometry {
25
26#ifndef DOXYGEN_NO_DISPATCH
27namespace detail_dispatch {
28
29// Returns single geometry by Id
30// for single geometries returns the geometry itself
31template <typename Geometry,
32 bool IsMulti = boost::is_base_of
33 <
34 multi_tag,
35 typename geometry::tag<Geometry>::type
36 >::value
37>
38struct single_geometry
39{
40 typedef Geometry & return_type;
41
42 template <typename Id>
43 static inline return_type apply(Geometry & g, Id const& ) { return g; }
44};
45
46// for multi geometries returns one of the stored single geometries
47template <typename Geometry>
48struct single_geometry<Geometry, true>
49{
50 typedef typename boost::range_reference<Geometry>::type return_type;
51
52 template <typename Id>
53 static inline return_type apply(Geometry & g, Id const& id)
54 {
55 BOOST_GEOMETRY_ASSERT(id.multi_index >= 0);
56 typedef typename boost::range_size<Geometry>::type size_type;
57 return range::at(g, static_cast<size_type>(id.multi_index));
58 }
59};
60
61} // namespace detail_dispatch
62#endif // DOXYGEN_NO_DISPATCH
63
64#ifndef DOXYGEN_NO_DETAIL
65namespace detail {
66
67template <typename Geometry>
68struct single_geometry_return_type
69{
70 typedef typename detail_dispatch::single_geometry<Geometry>::return_type type;
71};
72
73template <typename Geometry, typename Id>
74inline
75typename single_geometry_return_type<Geometry>::type
76single_geometry(Geometry & geometry, Id const& id)
77{
78 return detail_dispatch::single_geometry<Geometry>::apply(geometry, id);
79}
80
81template <typename Geometry, typename Id>
82inline
83typename single_geometry_return_type<Geometry const>::type
84single_geometry(Geometry const& geometry, Id const& id)
85{
86 return detail_dispatch::single_geometry<Geometry const>::apply(geometry, id);
87}
88
89} // namespace detail
90#endif // DOXYGEN_NO_DETAIL
91
92}} // namespace boost::geometry
93
94#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SINGLE_GEOMETRY_HPP