Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:23

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2020-2023.
0008 // Modifications copyright (c) 2020-2023 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 
0012 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0013 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0014 
0015 // Use, modification and distribution is subject to the Boost Software License,
0016 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
0018 
0019 #ifndef BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP
0020 #define BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP
0021 
0022 
0023 #include <type_traits>
0024 
0025 #include <boost/range/size_type.hpp>
0026 #include <boost/range/value_type.hpp>
0027 
0028 
0029 namespace boost { namespace geometry
0030 {
0031 
0032 
0033 namespace traits
0034 {
0035 
0036 /*!
0037 \brief Metafunction to define the argument passed to the three
0038     traits classes clear, push_back and resize
0039 \ingroup mutable_range
0040  */
0041 template <typename Range>
0042 struct rvalue_type
0043 {
0044     typedef typename std::remove_reference<Range>::type& type;
0045 };
0046 
0047 
0048 /*!
0049 \brief Traits class to clear a geometry
0050 \ingroup mutable_range
0051  */
0052 template <typename Range>
0053 struct clear
0054 {
0055     static inline void apply(typename rvalue_type<Range>::type range)
0056     {
0057         range.clear();
0058     }
0059 };
0060 
0061 
0062 /*!
0063 \brief Traits class to append a point to a range (ring, linestring, multi*)
0064 \ingroup mutable_range
0065  */
0066 template <typename Range>
0067 struct push_back
0068 {
0069     typedef typename boost::range_value
0070         <
0071             typename std::remove_reference<Range>::type
0072         >::type item_type;
0073 
0074     static inline void apply(typename rvalue_type<Range>::type range,
0075                  item_type const& item)
0076     {
0077         range.push_back(item);
0078     }
0079 
0080     static inline void apply(typename rvalue_type<Range>::type range,
0081                  item_type && item)
0082     {
0083         range.push_back(std::move(item));
0084     }
0085 };
0086 
0087 
0088 /*!
0089 \brief Traits class to append an element of geometry collection
0090 \ingroup mutable_range
0091  */
0092 template <typename Range>
0093 struct emplace_back
0094 {
0095     // When specializing it'd be enough to only implement it for one argument
0096     // because we'll use it to pass one object of type potentially different
0097     // than range_value but which range_value can be constructed from.
0098     template <typename ...Args>
0099     static inline void apply(typename rvalue_type<Range>::type range,
0100                              Args&&... args)
0101     {
0102         range.emplace_back(std::forward<Args>(args)...);
0103     }
0104 };
0105 
0106 
0107 /*!
0108 \brief Traits class to append a point to a range (ring, linestring, multi*)
0109 \ingroup mutable_range
0110  */
0111 template <typename Range>
0112 struct resize
0113 {
0114     using size_type = typename boost::range_size
0115         <
0116             typename std::remove_reference<Range>::type
0117         >::type;
0118 
0119     static inline void apply(typename rvalue_type<Range>::type range,
0120                              size_type new_size)
0121     {
0122         range.resize(new_size);
0123     }
0124 };
0125 
0126 
0127 } // namespace traits
0128 
0129 
0130 }} // namespace boost::geometry
0131 
0132 
0133 #endif // BOOST_GEOMETRY_CORE_MUTABLE_RANGE_HPP