Check all subgeometry types in DG and GC concept checks.

This commit is contained in:
Adam Wulkiewicz
2021-06-02 22:29:39 +02:00
parent fd32e7b88e
commit 620e02f4b6
5 changed files with 115 additions and 53 deletions

View File

@@ -238,8 +238,6 @@ struct append<Geometry, RangeOrPoint, dynamic_geometry_tag, OtherTag>
{
traits::visit<Geometry>::apply([&](auto & g)
{
concepts::check<std::remove_reference_t<decltype(g)>>();
append
<
std::remove_reference_t<decltype(g)>, RangeOrPoint
@@ -273,6 +271,8 @@ template <typename Geometry, typename RangeOrPoint>
inline void append(Geometry& geometry, RangeOrPoint const& range_or_point,
signed_size_type ring_index = -1, signed_size_type multi_index = 0)
{
concepts::check<Geometry>();
dispatch::append
<
Geometry, RangeOrPoint

View File

@@ -19,7 +19,6 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_AREA_HPP
#define BOOST_GEOMETRY_ALGORITHMS_AREA_HPP
#include <boost/concept_check.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>

View File

@@ -22,7 +22,6 @@
#include <iterator>
#include <boost/concept_check.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>

View File

@@ -11,12 +11,16 @@
#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DYNAMIC_GEOMETRY_CONCEPT_HPP
#include <utility>
#include <boost/concept_check.hpp>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/visit.hpp>
#include <boost/geometry/geometries/concepts/box_concept.hpp>
#include <boost/geometry/geometries/concepts/concept_type.hpp>
#include <boost/geometry/geometries/concepts/geometry_collection_concept.hpp>
#include <boost/geometry/geometries/concepts/linestring_concept.hpp>
#include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
@@ -27,29 +31,46 @@
#include <boost/geometry/geometries/concepts/ring_concept.hpp>
#include <boost/geometry/geometries/concepts/segment_concept.hpp>
#include <boost/geometry/util/sequence.hpp>
namespace boost { namespace geometry { namespace concepts
{
namespace detail
{
template <typename Geometry, typename SubGeometry>
struct GeometryType<Geometry, SubGeometry, dynamic_geometry_tag, false>
: concepts::concept_type<SubGeometry>::type
{
#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
BOOST_CONCEPT_USAGE(GeometryType)
{
Geometry* dg = nullptr;
SubGeometry* sg = nullptr;
*dg = std::move(*sg);
}
#endif // DOXYGEN_NO_CONCEPT_MEMBERS
};
template <typename Geometry, typename SubGeometry>
struct GeometryType<Geometry const, SubGeometry, dynamic_geometry_tag, false>
: concepts::concept_type<SubGeometry const>::type
{};
} // namespace detail
template <typename Geometry>
class DynamicGeometry
struct DynamicGeometry
{
#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
using sequence_t = typename traits::geometry_types<Geometry>::type;
using first_t = typename util::sequence_front<sequence_t>::type;
BOOST_CONCEPT_ASSERT( (typename concepts::concept_type<first_t>::type) );
public:
BOOST_CONCEPT_ASSERT((detail::GeometryTypes<Geometry, sequence_t>));
BOOST_CONCEPT_USAGE(DynamicGeometry)
{
Geometry* dg = 0;
first_t* g = 0;
*dg = *g;
Geometry* dg = nullptr;
traits::visit<Geometry>::apply([](auto &&) {}, *dg);
}
#endif // DOXYGEN_NO_CONCEPT_MEMBERS
@@ -57,19 +78,15 @@ public:
template <typename Geometry>
class ConstDynamicGeometry
struct ConstDynamicGeometry
{
#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
using sequence_t = typename traits::geometry_types<Geometry>::type;
using first_t = typename util::sequence_front<sequence_t>::type;
BOOST_CONCEPT_ASSERT( (typename concepts::concept_type<first_t const>::type) );
public:
BOOST_CONCEPT_ASSERT((detail::GeometryTypes<Geometry const, sequence_t>));
BOOST_CONCEPT_USAGE(ConstDynamicGeometry)
{
Geometry const* dg = 0;
Geometry const* dg = nullptr;
traits::visit<Geometry>::apply([](auto &&) {}, *dg);
}
#endif // DOXYGEN_NO_CONCEPT_MEMBERS

View File

@@ -11,14 +11,19 @@
#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP
#include <utility>
#include <boost/concept_check.hpp>
#include <boost/range/concepts.hpp>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/mutable_range.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/visit.hpp>
#include <boost/geometry/geometries/concepts/box_concept.hpp>
#include <boost/geometry/geometries/concepts/concept_type.hpp>
#include <boost/geometry/geometries/concepts/linestring_concept.hpp>
#include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
#include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
@@ -35,30 +40,81 @@
namespace boost { namespace geometry { namespace concepts
{
template <typename Geometry>
class GeometryCollection
namespace detail
{
template
<
typename Geometry,
typename SubGeometry,
typename Tag = typename tag<Geometry>::type,
bool IsSubDynamicOrCollection = util::is_dynamic_geometry<SubGeometry>::value
|| util::is_geometry_collection<SubGeometry>::value
>
struct GeometryType;
// Prevent recursive concept checking
template <typename Geometry, typename SubGeometry, typename Tag>
struct GeometryType<Geometry, SubGeometry, Tag, true> {};
template <typename Geometry, typename SubGeometry, typename Tag>
struct GeometryType<Geometry const, SubGeometry, Tag, true> {};
template <typename Geometry, typename SubGeometry>
struct GeometryType<Geometry, SubGeometry, geometry_collection_tag, false>
: concepts::concept_type<SubGeometry>::type
{
#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) );
BOOST_CONCEPT_USAGE(GeometryType)
{
Geometry* gc = nullptr;
SubGeometry* sg = nullptr;
traits::emplace_back<Geometry>::apply(*gc, std::move(*sg));
}
#endif // DOXYGEN_NO_CONCEPT_MEMBERS
};
template <typename Geometry, typename SubGeometry>
struct GeometryType<Geometry const, SubGeometry, geometry_collection_tag, false>
: concepts::concept_type<SubGeometry const>::type
{};
template <typename Geometry, typename ...SubGeometries>
struct GeometryTypesPack {};
template <typename Geometry, typename SubGeometry, typename ...SubGeometries>
struct GeometryTypesPack<Geometry, SubGeometry, SubGeometries...>
: GeometryTypesPack<Geometry, SubGeometries...>
, GeometryType<Geometry, SubGeometry>
{};
template <typename Geometry, typename SubGeometriesSequence>
struct GeometryTypes;
template <typename Geometry, typename ...SubGeometries>
struct GeometryTypes<Geometry, util::type_sequence<SubGeometries...>>
: GeometryTypesPack<Geometry, SubGeometries...>
{};
} // namespace detail
template <typename Geometry>
struct GeometryCollection
: boost::ForwardRangeConcept<Geometry>
{
#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
using sequence_t = typename traits::geometry_types<Geometry>::type;
using first_t = typename util::sequence_front<sequence_t>::type;
// NOTE: It is possible to relax this requirement.
BOOST_GEOMETRY_STATIC_ASSERT((! util::is_geometry_collection<first_t>::value),
"The first type can't be a geometry collection.",
Geometry);
BOOST_CONCEPT_ASSERT( (typename concepts::concept_type<first_t>::type) );
public:
BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry, sequence_t>) );
BOOST_CONCEPT_USAGE(GeometryCollection)
{
Geometry* gc = 0;
first_t* g = 0;
traits::clear<Geometry>::apply(*gc);
traits::emplace_back<Geometry>::apply(*gc, *g);
Geometry* gc = nullptr;
traits::clear<Geometry>::apply(*gc);
traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
}
#endif // DOXYGEN_NO_CONCEPT_MEMBERS
@@ -66,25 +122,16 @@ public:
template <typename Geometry>
class ConstGeometryCollection
struct ConstGeometryCollection
: boost::ForwardRangeConcept<Geometry>
{
#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) );
using sequence_t = typename traits::geometry_types<Geometry>::type;
using first_t = typename util::sequence_front<sequence_t>::type;
// NOTE: It is possible to relax this requirement.
BOOST_GEOMETRY_STATIC_ASSERT((! util::is_geometry_collection<first_t>::value),
"The first type can't be a geometry collection.",
Geometry);
BOOST_CONCEPT_ASSERT( (typename concepts::concept_type<first_t const>::type) );
public:
BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry const, sequence_t>) );
BOOST_CONCEPT_USAGE(ConstGeometryCollection)
{
Geometry const* gc = 0;
Geometry const* gc = nullptr;
traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
}
#endif // DOXYGEN_NO_CONCEPT_MEMBERS