-
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.
[experimental] update test-demo with version with lambdas
- Loading branch information
1 parent
a8bd9a0
commit 17ae254
Showing
3 changed files
with
178 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Boost.Geometry (aka GGL, Generic Geometry Library) | ||
# Robustness Test - partition and within | ||
# | ||
# 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) | ||
|
||
|
||
project partition_within | ||
: requirements | ||
<include>. | ||
<link>static | ||
; | ||
|
||
exe partition_within : partition_within.cpp ; |
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,103 @@ | ||
// Boost.Geometry (aka GGL, Generic Geometry Library) | ||
|
||
// 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 BOOST_GEOMETRY_EXPERIMENTAL_LAMBDA_PARTITION_HPP | ||
#define BOOST_GEOMETRY_EXPERIMENTAL_LAMBDA_PARTITION_HPP | ||
|
||
#include <boost/range.hpp> | ||
#include <boost/geometry/algorithms/detail/partition.hpp> | ||
|
||
#include <functional> | ||
|
||
namespace boost { namespace geometry | ||
{ | ||
|
||
namespace experimental | ||
{ | ||
|
||
template <typename F> | ||
struct adapt_partition_visitor | ||
{ | ||
F m_f; | ||
|
||
explicit adapt_partition_visitor(F&& f) | ||
: m_f(std::move(f)) | ||
{} | ||
|
||
template <typename ...Ts> | ||
decltype(auto) apply(Ts&& ...is) const | ||
{ | ||
return m_f(std::forward<Ts>(is)...); | ||
} | ||
}; | ||
|
||
struct partition_options | ||
{ | ||
using include_policy = detail::partition::include_all_policy; | ||
std::size_t min_elements = 16; | ||
}; | ||
|
||
template | ||
< | ||
typename BoxType, | ||
typename ForwardRange1, | ||
typename ForwardRange2, | ||
typename Options = partition_options | ||
> | ||
bool lambda_partition(ForwardRange1 const& forward_range1, | ||
ForwardRange2 const& forward_range2, | ||
const std::function | ||
< | ||
void(BoxType&, | ||
typename boost::range_value<ForwardRange1>::type const&) | ||
>& expand_policy1, | ||
const std::function | ||
< | ||
bool(BoxType const&, | ||
typename boost::range_value<ForwardRange1>::type const&) | ||
>& overlaps_policy1, | ||
const std::function | ||
< | ||
void(BoxType&, | ||
typename boost::range_value<ForwardRange2>::type const&) | ||
>& expand_policy2, | ||
const std::function | ||
< | ||
bool(BoxType const&, | ||
typename boost::range_value<ForwardRange2>::type const&) | ||
>& overlaps_policy2, | ||
const std::function | ||
< | ||
bool(typename boost::range_value<ForwardRange1>::type const&, | ||
typename boost::range_value<ForwardRange2>::type const&) | ||
>& visitor, | ||
const std::function | ||
< | ||
void(BoxType const&, int level) | ||
>& box_visitor = [](auto const&, int) {}, | ||
const Options& options = {}) | ||
{ | ||
adapt_partition_visitor<decltype(visitor)> av(visitor); | ||
adapt_partition_visitor<decltype(expand_policy1)> aev1(expand_policy1); | ||
adapt_partition_visitor<decltype(expand_policy2)> aev2(expand_policy2); | ||
adapt_partition_visitor<decltype(overlaps_policy1)> aov1(overlaps_policy1); | ||
adapt_partition_visitor<decltype(overlaps_policy2)> aov2(overlaps_policy2); | ||
adapt_partition_visitor<decltype(box_visitor)> apbv(box_visitor); | ||
|
||
return partition | ||
< | ||
BoxType, | ||
typename Options::include_policy, | ||
typename Options::include_policy | ||
>::apply(forward_range1, forward_range2, av, | ||
aev1, aov1, | ||
aev2, aov2, options.min_elements, apbv); | ||
} | ||
|
||
}}} // namespace boost::geometry::experimental | ||
|
||
#endif // BOOST_GEOMETRY_EXPERIMENTAL_LAMBDA_PARTITION_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