mirror of
https://github.com/boostorg/geometry.git
synced 2026-01-29 19:42:10 +00:00
Replace add_const_if_c with transcribe_const.
Move add_const_if_c to util/type_traits.hpp Remove usage when not needed.
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2020.
|
||||
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
@@ -19,8 +23,6 @@
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/util/add_const_if_c.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
@@ -31,22 +33,20 @@ namespace dispatch
|
||||
{
|
||||
|
||||
|
||||
template <typename GeometryTag, typename Geometry, typename Range, bool IsConst>
|
||||
template <typename GeometryTag, typename Geometry, typename Range>
|
||||
struct as_range
|
||||
{
|
||||
static inline typename add_const_if_c<IsConst, Range>::type& get(
|
||||
typename add_const_if_c<IsConst, Geometry>::type& input)
|
||||
static inline Range& get(Geometry& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry, typename Range, bool IsConst>
|
||||
struct as_range<polygon_tag, Geometry, Range, IsConst>
|
||||
template <typename Geometry, typename Range>
|
||||
struct as_range<polygon_tag, Geometry, Range>
|
||||
{
|
||||
static inline typename add_const_if_c<IsConst, Range>::type& get(
|
||||
typename add_const_if_c<IsConst, Geometry>::type& input)
|
||||
static inline Range& get(Geometry& input)
|
||||
{
|
||||
return exterior_ring(input);
|
||||
}
|
||||
@@ -73,8 +73,7 @@ inline Range& as_range(Geometry& input)
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
Geometry,
|
||||
Range,
|
||||
false
|
||||
Range
|
||||
>::get(input);
|
||||
}
|
||||
|
||||
@@ -91,9 +90,8 @@ inline Range const& as_range(Geometry const& input)
|
||||
return dispatch::as_range
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
Geometry,
|
||||
Range,
|
||||
true
|
||||
Geometry const,
|
||||
Range const
|
||||
>::get(input);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <boost/geometry/core/tag_cast.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/util/add_const_if_c.hpp>
|
||||
#include <boost/geometry/util/type_traits.hpp>
|
||||
|
||||
#include <boost/geometry/views/box_view.hpp>
|
||||
#include <boost/geometry/views/segment_view.hpp>
|
||||
@@ -195,11 +195,11 @@ struct for_each_range<Geometry, multi_linestring_tag>
|
||||
Geometry,
|
||||
detail::for_each::fe_range_range
|
||||
<
|
||||
typename add_const_if_c
|
||||
detail::transcribe_const_t
|
||||
<
|
||||
std::is_const<Geometry>::value,
|
||||
Geometry,
|
||||
typename boost::range_value<Geometry>::type
|
||||
>::type
|
||||
>
|
||||
>
|
||||
>
|
||||
{};
|
||||
@@ -212,11 +212,11 @@ struct for_each_range<Geometry, multi_polygon_tag>
|
||||
Geometry,
|
||||
detail::for_each::fe_range_polygon
|
||||
<
|
||||
typename add_const_if_c
|
||||
detail::transcribe_const_t
|
||||
<
|
||||
std::is_const<Geometry>::value,
|
||||
Geometry,
|
||||
typename boost::range_value<Geometry>::type
|
||||
>::type
|
||||
>
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/range.hpp>
|
||||
|
||||
@@ -40,8 +39,8 @@
|
||||
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
|
||||
#include <boost/geometry/util/add_const_if_c.hpp>
|
||||
#include <boost/geometry/util/range.hpp>
|
||||
#include <boost/geometry/util/type_traits.hpp>
|
||||
|
||||
#include <boost/geometry/views/detail/indexed_point_view.hpp>
|
||||
|
||||
@@ -108,21 +107,21 @@ struct fe_segment_segment
|
||||
template <typename Range>
|
||||
struct fe_range_value
|
||||
{
|
||||
typedef typename add_const_if_c
|
||||
typedef detail::transcribe_const_t
|
||||
<
|
||||
std::is_const<Range>::value,
|
||||
Range,
|
||||
typename boost::range_value<Range>::type
|
||||
>::type type;
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename Range>
|
||||
struct fe_point_type
|
||||
{
|
||||
typedef typename add_const_if_c
|
||||
typedef detail::transcribe_const_t
|
||||
<
|
||||
std::is_const<Range>::value,
|
||||
Range,
|
||||
typename point_type<Range>::type
|
||||
>::type type;
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/util/add_const_if_c.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -83,11 +82,7 @@ struct exterior_ring<polygon_tag, Polygon>
|
||||
{
|
||||
static
|
||||
typename geometry::ring_return_type<Polygon>::type
|
||||
apply(typename add_const_if_c
|
||||
<
|
||||
std::is_const<Polygon>::type::value,
|
||||
Polygon
|
||||
>::type& polygon)
|
||||
apply(Polygon& polygon)
|
||||
{
|
||||
return traits::exterior_ring
|
||||
<
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2020.
|
||||
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
@@ -20,7 +24,7 @@
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
#include <boost/geometry/util/add_const_if_c.hpp>
|
||||
#include <boost/geometry/util/type_traits.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -55,11 +59,7 @@ private :
|
||||
// Might be replaced declaring as BOOST_AUTO
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
typename add_const_if_c
|
||||
<
|
||||
boost::is_const<Geometry>::value,
|
||||
range_type
|
||||
>::type
|
||||
detail::transcribe_const_t<Geometry, range_type>
|
||||
>::type iterator_type;
|
||||
|
||||
iterator_type m_begin, m_end;
|
||||
|
||||
@@ -19,42 +19,10 @@
|
||||
#define BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP
|
||||
|
||||
|
||||
#include <type_traits>
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
BOOST_HEADER_DEPRECATED("<boost/geometry/util/type_traits.hpp>")
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Meta-function to define a const or non const type
|
||||
\ingroup utility
|
||||
\details If the boolean template parameter is true, the type parameter
|
||||
will be defined as const, otherwise it will be defined as it was.
|
||||
This meta-function is used to have one implementation for both
|
||||
const and non const references
|
||||
\note This traits class is completely independant from Boost.Geometry
|
||||
and might be a separate addition to Boost
|
||||
\note Used in a.o. for_each, interior_rings, exterior_ring
|
||||
\par Example
|
||||
\code
|
||||
void foo(typename add_const_if_c<IsConst, Point>::type& point)
|
||||
\endcode
|
||||
*/
|
||||
template <bool IsConst, typename Type>
|
||||
struct add_const_if_c
|
||||
{
|
||||
typedef std::conditional_t
|
||||
<
|
||||
IsConst,
|
||||
Type const,
|
||||
Type
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
#include <boost/geometry/util/type_traits.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2020.
|
||||
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
@@ -16,7 +20,6 @@
|
||||
|
||||
#include <boost/concept/requires.hpp>
|
||||
#include <boost/geometry/geometries/concepts/point_concept.hpp>
|
||||
#include <boost/geometry/util/add_const_if_c.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
@@ -25,36 +28,31 @@ namespace boost { namespace geometry
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Point, int Dimension, int DimensionCount, bool IsConst>
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
int Dimension = 0,
|
||||
int DimensionCount = dimension<Point>::value
|
||||
>
|
||||
struct coordinates_scanner
|
||||
{
|
||||
template <typename Op>
|
||||
static inline Op apply(typename add_const_if_c
|
||||
<
|
||||
IsConst,
|
||||
Point
|
||||
>::type& point, Op operation)
|
||||
static inline Op apply(Point& point, Op operation)
|
||||
{
|
||||
operation.template apply<Point, Dimension>(point);
|
||||
return coordinates_scanner
|
||||
<
|
||||
Point,
|
||||
Dimension+1,
|
||||
DimensionCount,
|
||||
IsConst
|
||||
Dimension + 1
|
||||
>::apply(point, operation);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Point, int DimensionCount, bool IsConst>
|
||||
struct coordinates_scanner<Point, DimensionCount, DimensionCount, IsConst>
|
||||
template <typename Point, int DimensionCount>
|
||||
struct coordinates_scanner<Point, DimensionCount, DimensionCount>
|
||||
{
|
||||
template <typename Op>
|
||||
static inline Op apply(typename add_const_if_c
|
||||
<
|
||||
IsConst,
|
||||
Point
|
||||
>::type& , Op operation)
|
||||
static inline Op apply(Point& , Op operation)
|
||||
{
|
||||
return operation;
|
||||
}
|
||||
@@ -68,12 +66,7 @@ inline void for_each_coordinate(Point& point, Op operation)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
|
||||
|
||||
typedef typename detail::coordinates_scanner
|
||||
<
|
||||
Point, 0, dimension<Point>::type::value, false
|
||||
> scanner;
|
||||
|
||||
scanner::apply(point, operation);
|
||||
detail::coordinates_scanner<Point>::apply(point, operation);
|
||||
}
|
||||
|
||||
template <typename Point, typename Op>
|
||||
@@ -81,12 +74,7 @@ inline Op for_each_coordinate(Point const& point, Op operation)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<Point>) );
|
||||
|
||||
typedef typename detail::coordinates_scanner
|
||||
<
|
||||
Point, 0, dimension<Point>::type::value, true
|
||||
> scanner;
|
||||
|
||||
return scanner::apply(point, operation);
|
||||
return detail::coordinates_scanner<Point const>::apply(point, operation);
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
This folder contains several headerfiles not fitting in one of the other folders,
|
||||
or meta-functions which would fit into boost as a separate trait or utility,
|
||||
such as add_const_if_c
|
||||
|
||||
@@ -310,10 +310,53 @@ template <typename T>
|
||||
using remove_cref_t = typename remove_cref<T>::type;
|
||||
|
||||
|
||||
|
||||
template <typename From, typename To>
|
||||
struct transcribe_const
|
||||
{
|
||||
using type = std::conditional_t
|
||||
<
|
||||
std::is_const<std::remove_reference_t<From>>::value,
|
||||
std::add_const_t<To>,
|
||||
To
|
||||
>;
|
||||
};
|
||||
|
||||
template <typename From, typename To>
|
||||
using transcribe_const_t = typename transcribe_const<From, To>::type;
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
/*!
|
||||
\brief Meta-function to define a const or non const type
|
||||
\ingroup utility
|
||||
\details If the boolean template parameter is true, the type parameter
|
||||
will be defined as const, otherwise it will be defined as it was.
|
||||
This meta-function is used to have one implementation for both
|
||||
const and non const references
|
||||
\note This traits class is completely independant from Boost.Geometry
|
||||
and might be a separate addition to Boost
|
||||
\note Used in a.o. for_each, interior_rings, exterior_ring
|
||||
\par Example
|
||||
\code
|
||||
void foo(typename add_const_if_c<IsConst, Point>::type& point)
|
||||
\endcode
|
||||
*/
|
||||
template <bool IsConst, typename Type>
|
||||
struct add_const_if_c
|
||||
{
|
||||
typedef std::conditional_t
|
||||
<
|
||||
IsConst,
|
||||
Type const,
|
||||
Type
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP
|
||||
|
||||
Reference in New Issue
Block a user