Skip to content

Commit c6e83fd

Browse files
committed
Add if constexpr macro and replace condition macro.
1 parent b6a7349 commit c6e83fd

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

include/boost/geometry/algorithms/densify.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Boost.Geometry
22

3-
// Copyright (c) 2017-2021, Oracle and/or its affiliates.
3+
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
44

5+
// Copyright (c) 2017-2021, Oracle and/or its affiliates.
56
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
67

78
// Licensed under the Boost Software License version 1.0.
@@ -33,7 +34,7 @@
3334
#include <boost/geometry/strategies/densify/geographic.hpp>
3435
#include <boost/geometry/strategies/densify/spherical.hpp>
3536
#include <boost/geometry/strategies/detail.hpp>
36-
#include <boost/geometry/util/condition.hpp>
37+
#include <boost/geometry/util/constexpr.hpp>
3738
#include <boost/geometry/util/range.hpp>
3839

3940

@@ -102,7 +103,7 @@ struct densify_range
102103
strategy.apply(p0, p1, policy, len);
103104
}
104105

105-
if (BOOST_GEOMETRY_CONDITION(AppendLastPoint))
106+
if BOOST_GEOMETRY_CONSTEXPR (AppendLastPoint)
106107
{
107108
convert_and_push_back(rng_out, *prev); // back(rng)
108109
}
@@ -130,7 +131,7 @@ struct densify_ring
130131

131132
strategy.apply(p0, p1, policy, len);
132133

133-
if (BOOST_GEOMETRY_CONDITION(IsClosed2))
134+
if BOOST_GEOMETRY_CONSTEXPR (IsClosed2)
134135
{
135136
convert_and_push_back(ring_out, p1);
136137
}

include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Boost.Geometry (aka GGL, Generic Geometry Library)
22

33
// Copyright (c) 2012-2020 Barend Gehrels, Amsterdam, the Netherlands.
4-
// Copyright (c) 2022 Adam Wulkiewicz, Lodz, Poland.
4+
// Copyright (c) 2022-2023 Adam Wulkiewicz, Lodz, Poland.
55

66
// This file was modified by Oracle on 2017-2022.
77
// Modifications copyright (c) 2017-2022 Oracle and/or its affiliates.
@@ -44,7 +44,7 @@
4444
#include <boost/geometry/strategies/buffer.hpp>
4545
#include <boost/geometry/strategies/side.hpp>
4646

47-
#include <boost/geometry/util/condition.hpp>
47+
#include <boost/geometry/util/constexpr.hpp>
4848
#include <boost/geometry/util/math.hpp>
4949
#include <boost/geometry/util/type_traits.hpp>
5050

@@ -942,17 +942,17 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
942942
{
943943
boost::ignore_unused(visit_pieces_policy);
944944

945-
typedef detail::buffer::buffered_piece_collection
946-
<
947-
typename geometry::ring_type<GeometryOutput>::type,
948-
Strategies,
949-
DistanceStrategy,
950-
RobustPolicy
951-
> collection_type;
945+
using collection_type = detail::buffer::buffered_piece_collection
946+
<
947+
typename geometry::ring_type<GeometryOutput>::type,
948+
Strategies,
949+
DistanceStrategy,
950+
RobustPolicy
951+
>;
952952
collection_type collection(strategies, distance_strategy, robust_policy);
953953
collection_type const& const_collection = collection;
954954

955-
bool const areal = util::is_areal<GeometryInput>::value;
955+
static constexpr bool areal = util::is_areal<GeometryInput>::value;
956956

957957
dispatch::buffer_inserter
958958
<
@@ -969,7 +969,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
969969
robust_policy, strategies);
970970

971971
collection.get_turns();
972-
if (BOOST_GEOMETRY_CONDITION(areal))
972+
if BOOST_GEOMETRY_CONSTEXPR (areal)
973973
{
974974
collection.check_turn_in_original();
975975
}
@@ -989,7 +989,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
989989
// phase 1: turns (after enrichment/clustering)
990990
visit_pieces_policy.apply(const_collection, 1);
991991

992-
if (BOOST_GEOMETRY_CONDITION(areal))
992+
if BOOST_GEOMETRY_CONSTEXPR (areal)
993993
{
994994
collection.deflate_check_turns();
995995
}
@@ -1001,8 +1001,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
10011001
// - the output is counter clockwise
10021002
// and avoid reversing twice
10031003
bool reverse = distance_strategy.negative() && areal;
1004-
if (BOOST_GEOMETRY_CONDITION(
1005-
geometry::point_order<GeometryOutput>::value == counterclockwise))
1004+
if BOOST_GEOMETRY_CONSTEXPR (geometry::point_order<GeometryOutput>::value == counterclockwise)
10061005
{
10071006
reverse = ! reverse;
10081007
}
@@ -1011,9 +1010,12 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
10111010
collection.reverse();
10121011
}
10131012

1014-
if (BOOST_GEOMETRY_CONDITION(distance_strategy.negative() && areal))
1013+
if BOOST_GEOMETRY_CONSTEXPR (areal)
10151014
{
1016-
collection.discard_nonintersecting_deflated_rings();
1015+
if (distance_strategy.negative())
1016+
{
1017+
collection.discard_nonintersecting_deflated_rings();
1018+
}
10171019
}
10181020

10191021
collection.template assign<GeometryOutput>(out);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Boost.Geometry
2+
3+
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
4+
5+
// Use, modification and distribution is subject to the Boost Software License,
6+
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
9+
#ifndef BOOST_GEOMETRY_UTIL_CONSTEXPR_HPP
10+
#define BOOST_GEOMETRY_UTIL_CONSTEXPR_HPP
11+
12+
13+
#include <boost/geometry/util/condition.hpp>
14+
15+
16+
#ifndef BOOST_NO_CXX17_IF_CONSTEXPR
17+
18+
#define BOOST_GEOMETRY_CONSTEXPR(CONDITION) constexpr (CONDITION)
19+
20+
#else
21+
22+
#define BOOST_GEOMETRY_CONSTEXPR(CONDITION) (BOOST_GEOMETRY_CONDITION(CONDITION))
23+
24+
#endif
25+
26+
27+
#endif // BOOST_GEOMETRY_UTIL_CONSTEXPR_HPP

0 commit comments

Comments
 (0)