-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] add custom, non copiable, non indexable geometries
- Loading branch information
1 parent
83dab2d
commit ee83f57
Showing
23 changed files
with
1,908 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Boost.Geometry | ||
# | ||
# Copyright (c) 2023 Barend Gehrels, 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) | ||
|
||
test-suite boost-geometry-geometries-custom-non-copiable | ||
: | ||
[ run custom_ring.cpp : : : : cnc_ring ] | ||
[ run custom_polygon.cpp : : : : cnc_polygon ] | ||
[ run custom_multi_polygon.cpp : : : : cnc_multi_polygon ] | ||
[ run custom_linestring.cpp : : : : cnc_linestring ] | ||
[ run custom_multi_linestring.cpp : : : : cnc_multi_linestring ] | ||
; |
92 changes: 92 additions & 0 deletions
92
test/geometries/custom_non_copiable/adapt_cnc_container.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Boost.Geometry | ||
|
||
// Copyright (c) 2023 Barend Gehrels, 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) | ||
|
||
|
||
#ifndef GEOMETRY_TEST_ADAPT_CNC_CONTAINER_HPP | ||
#define GEOMETRY_TEST_ADAPT_CNC_CONTAINER_HPP | ||
|
||
#include "cnc_container.hpp" | ||
|
||
// 1. Adapt to Boost.Geometry | ||
namespace boost { namespace geometry { namespace traits | ||
{ | ||
|
||
template <typename Item> | ||
struct clear<cnc_container<Item> > | ||
{ | ||
static void apply(cnc_container<Item>& container) | ||
{ | ||
container.custom_clear(); | ||
} | ||
}; | ||
|
||
template <typename Item> | ||
struct push_back<cnc_container<Item> > | ||
{ | ||
static void apply(cnc_container<Item>& container, Item const& item) | ||
{ | ||
container.custom_push_back(item); | ||
} | ||
static void apply(cnc_container<Item>& container, Item&& item) | ||
{ | ||
container.custom_push_back(std::move(item)); | ||
} | ||
}; | ||
|
||
template <typename Item> | ||
struct resize<cnc_container<Item> > | ||
{ | ||
static void apply(cnc_container<Item>& container, std::size_t new_size) | ||
{ | ||
container.custom_resize(new_size); | ||
} | ||
}; | ||
|
||
}}} // namespace boost::geometry::traits | ||
|
||
|
||
// 2a. Adapt to Boost.Range, meta-functions | ||
namespace boost | ||
{ | ||
template<typename Item> | ||
struct range_mutable_iterator<cnc_container<Item> > | ||
{ | ||
using type = decltype(std::declval<cnc_container<Item>>().custom_begin()); | ||
}; | ||
|
||
template<typename Item> | ||
struct range_const_iterator<cnc_container<Item> > | ||
{ | ||
using type = decltype(std::declval<cnc_container<Item>>().const_custom_begin()); | ||
}; | ||
|
||
|
||
} // namespace boost | ||
|
||
|
||
// 2b. Adapt to Boost.Range, part 2, ADP | ||
template<typename Item> | ||
auto range_begin(cnc_container<Item>& container) { return container.custom_begin(); } | ||
|
||
template<typename Item> | ||
auto range_begin(cnc_container<Item> const& container) { return container.const_custom_begin(); } | ||
|
||
template<typename Item> | ||
auto range_end(cnc_container<Item>& container) { return container.custom_end(); } | ||
|
||
template<typename Item> | ||
auto range_end(cnc_container<Item> const& container) { return container.const_custom_end(); } | ||
|
||
template<typename Item> | ||
std::size_t range_calculate_size(cnc_container<Item> const& container) { return container.custom_size(); } | ||
|
||
|
||
|
||
|
||
|
||
#endif // GEOMETRY_TEST_ADAPT_CNC_CONTAINER_HPP |
93 changes: 93 additions & 0 deletions
93
test/geometries/custom_non_copiable/adapt_cnc_linestring.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Boost.Geometry | ||
|
||
// Copyright (c) 2023 Barend Gehrels, 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) | ||
|
||
|
||
#ifndef GEOMETRY_TEST_ADAPT_CNC_LINESTRING_HPP | ||
#define GEOMETRY_TEST_ADAPT_CNC_LINESTRING_HPP | ||
|
||
#include "cnc_linestring.hpp" | ||
|
||
// 1. Adapt to Boost.Geometry | ||
namespace boost { namespace geometry { namespace traits | ||
{ | ||
|
||
template <typename Point> | ||
struct tag<cnc_linestring<Point>> | ||
{ | ||
using type = linestring_tag; | ||
}; | ||
|
||
// Implement traits for mutable actions | ||
// These are all optional traits (normally / default they are implemented | ||
// conforming std:: functionality) | ||
|
||
template <typename Point> | ||
struct clear<cnc_linestring<Point> > | ||
{ | ||
static void apply(cnc_linestring<Point>& geo) | ||
{ | ||
geo.custom_clear(); | ||
} | ||
}; | ||
|
||
template <typename Point> | ||
struct push_back<cnc_linestring<Point> > | ||
{ | ||
static void apply(cnc_linestring<Point>& geo, Point const& point) | ||
{ | ||
geo.custom_push_back(point); | ||
} | ||
}; | ||
|
||
template <typename Point> | ||
struct resize<cnc_linestring<Point> > | ||
{ | ||
static void apply(cnc_linestring<Point>& geo, std::size_t new_size) | ||
{ | ||
geo.custom_resize(new_size); | ||
} | ||
}; | ||
|
||
|
||
}}} | ||
|
||
// 2a. Adapt to Boost.Range, meta-functions | ||
namespace boost | ||
{ | ||
|
||
template<typename Point> | ||
struct range_mutable_iterator<cnc_linestring<Point> > | ||
{ | ||
using type = decltype(std::declval<cnc_linestring<Point>>().custom_begin()); | ||
}; | ||
|
||
template<typename Point> | ||
struct range_const_iterator<cnc_linestring<Point> > | ||
{ | ||
using type = decltype(std::declval<cnc_linestring<Point>>().const_custom_begin()); | ||
}; | ||
|
||
} | ||
|
||
// 2b. Adapt to Boost.Range, part 2, ADP | ||
template<typename Point> | ||
auto range_begin(cnc_linestring<Point>& geo) { return geo.custom_begin(); } | ||
|
||
template<typename Point> | ||
auto range_begin(cnc_linestring<Point> const& geo) { return geo.const_custom_begin(); } | ||
|
||
template<typename Point> | ||
auto range_end(cnc_linestring<Point>& geo) { return geo.custom_end(); } | ||
|
||
template<typename Point> | ||
auto range_end(cnc_linestring<Point> const& geo) { return geo.const_custom_end(); } | ||
|
||
template<typename Point> | ||
std::size_t range_calculate_size(cnc_linestring<Point> const& geo) { return geo.custom_size(); } | ||
|
||
#endif // GEOMETRY_TEST_ADAPT_CNC_LINESTRING_HPP |
93 changes: 93 additions & 0 deletions
93
test/geometries/custom_non_copiable/adapt_cnc_multi_linestring.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Boost.Geometry | ||
|
||
// Copyright (c) 2023 Barend Gehrels, 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) | ||
|
||
|
||
#ifndef GEOMETRY_TEST_ADAPT_CNC_MULTI_LINESTRING_HPP | ||
#define GEOMETRY_TEST_ADAPT_CNC_MULTI_LINESTRING_HPP | ||
|
||
#include "cnc_multi_linestring.hpp" | ||
|
||
// 1. Adapt to Boost.Geometry | ||
namespace boost { namespace geometry { namespace traits | ||
{ | ||
|
||
template <typename Linestring> | ||
struct tag<cnc_multi_linestring<Linestring>> | ||
{ | ||
using type = multi_linestring_tag; | ||
}; | ||
|
||
template <typename Linestring> | ||
struct clear<cnc_multi_linestring<Linestring> > | ||
{ | ||
static void apply(cnc_multi_linestring<Linestring>& multi) | ||
{ | ||
multi.custom_clear(); | ||
} | ||
}; | ||
|
||
template <typename Linestring> | ||
struct push_back<cnc_multi_linestring<Linestring> > | ||
{ | ||
static void apply(cnc_multi_linestring<Linestring>& multi, Linestring const& item) | ||
{ | ||
multi.custom_push_back(item); | ||
} | ||
static inline void apply(cnc_multi_linestring<Linestring>& multi, Linestring&& item) | ||
{ | ||
multi.custom_push_back_move(std::move(item)); | ||
} | ||
}; | ||
|
||
template <typename Linestring> | ||
struct resize<cnc_multi_linestring<Linestring> > | ||
{ | ||
static void apply(cnc_multi_linestring<Linestring>& multi, std::size_t new_size) | ||
{ | ||
multi.custom_resize(new_size); | ||
} | ||
}; | ||
|
||
|
||
}}} | ||
|
||
// 2a. Adapt to Boost.Range, meta-functions | ||
namespace boost | ||
{ | ||
|
||
template<typename Linestring> | ||
struct range_mutable_iterator<cnc_multi_linestring<Linestring> > | ||
{ | ||
using type = decltype(std::declval<cnc_multi_linestring<Linestring>>().custom_begin()); | ||
}; | ||
|
||
template<typename Linestring> | ||
struct range_const_iterator<cnc_multi_linestring<Linestring> > | ||
{ | ||
using type = decltype(std::declval<cnc_multi_linestring<Linestring>>().const_custom_begin()); | ||
}; | ||
|
||
} | ||
|
||
// 2b. Adapt to Boost.Range, part 2, ADP | ||
template<typename Linestring> | ||
auto range_begin(cnc_multi_linestring<Linestring>& geo) { return geo.custom_begin(); } | ||
|
||
template<typename Linestring> | ||
auto range_begin(cnc_multi_linestring<Linestring> const& geo) { return geo.const_custom_begin(); } | ||
|
||
template<typename Linestring> | ||
auto range_end(cnc_multi_linestring<Linestring>& geo) { return geo.custom_end(); } | ||
|
||
template<typename Linestring> | ||
auto range_end(cnc_multi_linestring<Linestring> const& geo) { return geo.const_custom_end(); } | ||
|
||
template<typename Linestring> | ||
std::size_t range_calculate_size(cnc_multi_linestring<Linestring> const& geo) { return geo.custom_size(); } | ||
|
||
#endif // GEOMETRY_TEST_ADAPT_CNC_MULTI_LINESTRING_HPP |
Oops, something went wrong.