summaryrefslogtreecommitdiff
path: root/boost/geometry/core/access.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/core/access.hpp')
-rw-r--r--boost/geometry/core/access.hpp161
1 files changed, 115 insertions, 46 deletions
diff --git a/boost/geometry/core/access.hpp b/boost/geometry/core/access.hpp
index a463b8cdc3..cdc8ff9cff 100644
--- a/boost/geometry/core/access.hpp
+++ b/boost/geometry/core/access.hpp
@@ -18,12 +18,13 @@
#include <cstddef>
#include <boost/mpl/assert.hpp>
-#include <boost/type_traits/remove_const.hpp>
#include <boost/concept_check.hpp>
+#include <boost/type_traits/is_pointer.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/util/bare_type.hpp>
namespace boost { namespace geometry
@@ -79,6 +80,52 @@ struct indexed_access {};
} // namespace traits
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template
+<
+ typename Geometry,
+ typename CoordinateType,
+ std::size_t Index,
+ std::size_t Dimension
+>
+struct indexed_access_non_pointer
+{
+ static inline CoordinateType get(Geometry const& geometry)
+ {
+ return traits::indexed_access<Geometry, Index, Dimension>::get(geometry);
+ }
+ static inline void set(Geometry& b, CoordinateType const& value)
+ {
+ traits::indexed_access<Geometry, Index, Dimension>::set(b, value);
+ }
+};
+
+template
+<
+ typename Geometry,
+ typename CoordinateType,
+ std::size_t Index,
+ std::size_t Dimension
+>
+struct indexed_access_pointer
+{
+ static inline CoordinateType get(Geometry const* geometry)
+ {
+ return traits::indexed_access<typename boost::remove_pointer<Geometry>::type, Index, Dimension>::get(*geometry);
+ }
+ static inline void set(Geometry* geometry, CoordinateType const& value)
+ {
+ traits::indexed_access<typename boost::remove_pointer<Geometry>::type, Index, Dimension>::set(*geometry, value);
+ }
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
#ifndef DOXYGEN_NO_DISPATCH
namespace core_dispatch
@@ -89,7 +136,9 @@ template
typename Tag,
typename Geometry,
typename
- CoordinateType, std::size_t Dimension
+ CoordinateType,
+ std::size_t Dimension,
+ typename IsPointer
>
struct access
{
@@ -103,7 +152,8 @@ template
typename Geometry,
typename CoordinateType,
std::size_t Index,
- std::size_t Dimension
+ std::size_t Dimension,
+ typename IsPointer
>
struct indexed_access
{
@@ -112,7 +162,7 @@ struct indexed_access
};
template <typename Point, typename CoordinateType, std::size_t Dimension>
-struct access<point_tag, Point, CoordinateType, Dimension>
+struct access<point_tag, Point, CoordinateType, Dimension, boost::false_type>
{
static inline CoordinateType get(Point const& point)
{
@@ -124,6 +174,20 @@ struct access<point_tag, Point, CoordinateType, Dimension>
}
};
+template <typename Point, typename CoordinateType, std::size_t Dimension>
+struct access<point_tag, Point, CoordinateType, Dimension, boost::true_type>
+{
+ static inline CoordinateType get(Point const* point)
+ {
+ return traits::access<typename boost::remove_pointer<Point>::type, Dimension>::get(*point);
+ }
+ static inline void set(Point* p, CoordinateType const& value)
+ {
+ traits::access<typename boost::remove_pointer<Point>::type, Dimension>::set(*p, value);
+ }
+};
+
+
template
<
typename Box,
@@ -131,17 +195,21 @@ template
std::size_t Index,
std::size_t Dimension
>
-struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension>
-{
- static inline CoordinateType get(Box const& box)
- {
- return traits::indexed_access<Box, Index, Dimension>::get(box);
- }
- static inline void set(Box& b, CoordinateType const& value)
- {
- traits::indexed_access<Box, Index, Dimension>::set(b, value);
- }
-};
+struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension, boost::false_type>
+ : detail::indexed_access_non_pointer<Box, CoordinateType, Index, Dimension>
+{};
+
+template
+<
+ typename Box,
+ typename CoordinateType,
+ std::size_t Index,
+ std::size_t Dimension
+>
+struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension, boost::true_type>
+ : detail::indexed_access_pointer<Box, CoordinateType, Index, Dimension>
+{};
+
template
<
@@ -150,17 +218,21 @@ template
std::size_t Index,
std::size_t Dimension
>
-struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension>
-{
- static inline CoordinateType get(Segment const& segment)
- {
- return traits::indexed_access<Segment, Index, Dimension>::get(segment);
- }
- static inline void set(Segment& segment, CoordinateType const& value)
- {
- traits::indexed_access<Segment, Index, Dimension>::set(segment, value);
- }
-};
+struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension, boost::false_type>
+ : detail::indexed_access_non_pointer<Segment, CoordinateType, Index, Dimension>
+{};
+
+
+template
+<
+ typename Segment,
+ typename CoordinateType,
+ std::size_t Index,
+ std::size_t Dimension
+>
+struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension, boost::true_type>
+ : detail::indexed_access_pointer<Segment, CoordinateType, Index, Dimension>
+{};
} // namespace core_dispatch
#endif // DOXYGEN_NO_DISPATCH
@@ -199,14 +271,13 @@ inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
{
boost::ignore_unused_variable_warning(dummy);
- typedef typename boost::remove_const<Geometry>::type ncg_type;
-
typedef core_dispatch::access
<
typename tag<Geometry>::type,
- ncg_type,
- typename coordinate_type<ncg_type>::type,
- Dimension
+ typename geometry::util::bare_type<Geometry>::type,
+ typename coordinate_type<Geometry>::type,
+ Dimension,
+ typename boost::is_pointer<Geometry>::type
> coord_access_type;
return coord_access_type::get(geometry);
@@ -234,14 +305,13 @@ inline void set(Geometry& geometry
{
boost::ignore_unused_variable_warning(dummy);
- typedef typename boost::remove_const<Geometry>::type ncg_type;
-
typedef core_dispatch::access
<
typename tag<Geometry>::type,
- ncg_type,
- typename coordinate_type<ncg_type>::type,
- Dimension
+ typename geometry::util::bare_type<Geometry>::type,
+ typename coordinate_type<Geometry>::type,
+ Dimension,
+ typename boost::is_pointer<Geometry>::type
> coord_access_type;
coord_access_type::set(geometry, value);
@@ -269,15 +339,14 @@ inline typename coordinate_type<Geometry>::type get(Geometry const& geometry
{
boost::ignore_unused_variable_warning(dummy);
- typedef typename boost::remove_const<Geometry>::type ncg_type;
-
typedef core_dispatch::indexed_access
<
typename tag<Geometry>::type,
- ncg_type,
- typename coordinate_type<ncg_type>::type,
+ typename geometry::util::bare_type<Geometry>::type,
+ typename coordinate_type<Geometry>::type,
Index,
- Dimension
+ Dimension,
+ typename boost::is_pointer<Geometry>::type
> coord_access_type;
return coord_access_type::get(geometry);
@@ -306,14 +375,14 @@ inline void set(Geometry& geometry
{
boost::ignore_unused_variable_warning(dummy);
- typedef typename boost::remove_const<Geometry>::type ncg_type;
-
typedef core_dispatch::indexed_access
<
- typename tag<Geometry>::type, ncg_type,
- typename coordinate_type<ncg_type>::type,
+ typename tag<Geometry>::type,
+ typename geometry::util::bare_type<Geometry>::type,
+ typename coordinate_type<Geometry>::type,
Index,
- Dimension
+ Dimension,
+ typename boost::is_pointer<Geometry>::type
> coord_access_type;
coord_access_type::set(geometry, value);