Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to boost::core::invoke_swap. Add missing includes. #1195

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions include/boost/geometry/formulas/karney_inverse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define BOOST_GEOMETRY_FORMULAS_KARNEY_INVERSE_HPP


#include <boost/core/invoke_swap.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/special_functions/hypot.hpp>

Expand Down Expand Up @@ -191,7 +192,7 @@ class karney_inverse
if (swap_point < 0)
{
lon12_sign *= -1;
swap(lat1, lat2);
boost::core::invoke_swap(lat1, lat2);
}

// Enforce lat1 to be <= 0.
Expand Down Expand Up @@ -448,9 +449,9 @@ class karney_inverse

if (swap_point < 0)
{
swap(sin_alpha1, sin_alpha2);
swap(cos_alpha1, cos_alpha2);
swap(result.geodesic_scale, M21);
boost::core::invoke_swap(sin_alpha1, sin_alpha2);
boost::core::invoke_swap(cos_alpha1, cos_alpha2);
boost::core::invoke_swap(result.geodesic_scale, M21);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, if I see it correctly, replace these calls (here) with just std::swap
And maybe on more places.
But for now this PR looks okay to me.

}

sin_alpha1 *= swap_point * lon12_sign;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_DYNAMIC_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_DYNAMIC_HPP

#include <utility>
#include <boost/container/allocator_traits.hpp>
#include <boost/container/vector.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant.hpp>
Expand Down Expand Up @@ -184,7 +186,7 @@ class allocators<Allocator, Value, Parameters, Box, node_variant_dynamic_tag>

void swap(allocators & a)
{
boost::swap(node_allocator(), a.node_allocator());
boost::core::invoke_swap(node_allocator(), a.node_allocator());
}

bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP

#include <utility>
#include <boost/container/allocator_traits.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant.hpp>

#include <boost/geometry/index/detail/rtree/node/variant_dynamic.hpp>
#include <boost/geometry/index/detail/varray.hpp>

Expand Down Expand Up @@ -146,7 +152,7 @@ class allocators<Allocator, Value, Parameters, Box, node_variant_static_tag>

void swap(allocators & a)
{
boost::swap(node_allocator(), a.node_allocator());
boost::core::invoke_swap(node_allocator(), a.node_allocator());
}

bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <boost/container/allocator_traits.hpp>
#include <boost/container/vector.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/core/swap.hpp>
#include <boost/core/invoke_swap.hpp>

#include <boost/geometry/index/detail/rtree/options.hpp>
#include <boost/geometry/index/detail/rtree/node/concept.hpp>
Expand Down Expand Up @@ -228,8 +228,8 @@ class allocators<Allocator, Value, Parameters, Box, node_weak_dynamic_tag>

void swap(allocators & a)
{
boost::swap(internal_node_allocator(), a.internal_node_allocator());
boost::swap(leaf_allocator(), a.leaf_allocator());
boost::core::invoke_swap(internal_node_allocator(), a.internal_node_allocator());
boost::core::invoke_swap(leaf_allocator(), a.leaf_allocator());
}

bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP

#include <utility>
#include <boost/container/allocator_traits.hpp>
#include <boost/core/invoke_swap.hpp>

#include <boost/geometry/index/detail/rtree/node/weak_dynamic.hpp>
#include <boost/geometry/index/detail/varray.hpp>

Expand Down Expand Up @@ -155,8 +159,8 @@ class allocators<Allocator, Value, Parameters, Box, node_weak_static_tag>

void swap(allocators & a)
{
boost::swap(internal_node_allocator(), a.internal_node_allocator());
boost::swap(leaf_allocator(), a.leaf_allocator());
boost::core::invoke_swap(internal_node_allocator(), a.internal_node_allocator());
boost::core::invoke_swap(leaf_allocator(), a.leaf_allocator());
}

bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
Expand Down
4 changes: 2 additions & 2 deletions include/boost/geometry/index/detail/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <type_traits>

#include <boost/core/swap.hpp>
#include <boost/core/invoke_swap.hpp>

#ifndef BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP
Expand Down Expand Up @@ -40,7 +40,7 @@ static inline void move_cond(T &, T &, std::false_type) {}
template <typename T> inline
void swap_cond(T & l, T & r, std::true_type)
{
::boost::swap(l, r);
::boost::core::invoke_swap(l, r);
}

template <typename T> inline
Expand Down
2 changes: 0 additions & 2 deletions include/boost/geometry/index/detail/varray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <boost/concept_check.hpp>
#include <boost/config.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/core/swap.hpp>
#include <boost/integer.hpp>

// TODO - use std::reverse_iterator and std::iterator_traits
Expand Down Expand Up @@ -1566,7 +1565,6 @@ class varray
{
//std::iter_swap(first_sm, first_la);
//std::swap(*first_sm, *first_la); // may throw
//boost::swap(*first_sm, *first_la);
value_type temp(std::move(*first_sm)); // may throw
*first_sm = std::move(*first_la); // may throw
*first_la = std::move(temp); // may throw
Expand Down
31 changes: 16 additions & 15 deletions include/boost/geometry/index/rtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// Boost
#include <boost/container/new_allocator.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/core/invoke_swap.hpp>

// Boost.Geometry
#include <boost/geometry/core/static_assert.hpp>
Expand Down Expand Up @@ -657,9 +658,9 @@ class rtree
src.m_members.parameters(),
std::move(src.m_members.allocators()))
{
boost::swap(m_members.values_count, src.m_members.values_count);
boost::swap(m_members.leafs_level, src.m_members.leafs_level);
boost::swap(m_members.root, src.m_members.root);
boost::core::invoke_swap(m_members.values_count, src.m_members.values_count);
boost::core::invoke_swap(m_members.leafs_level, src.m_members.leafs_level);
boost::core::invoke_swap(m_members.root, src.m_members.root);
}

/*!
Expand All @@ -683,9 +684,9 @@ class rtree
{
if ( src.m_members.allocators() == allocator )
{
boost::swap(m_members.values_count, src.m_members.values_count);
boost::swap(m_members.leafs_level, src.m_members.leafs_level);
boost::swap(m_members.root, src.m_members.root);
boost::core::invoke_swap(m_members.values_count, src.m_members.values_count);
boost::core::invoke_swap(m_members.leafs_level, src.m_members.leafs_level);
boost::core::invoke_swap(m_members.root, src.m_members.root);
}
else
{
Expand Down Expand Up @@ -758,9 +759,9 @@ class rtree
m_members.equal_to() = src.m_members.equal_to();
m_members.parameters() = src.m_members.parameters();

boost::swap(m_members.values_count, src.m_members.values_count);
boost::swap(m_members.leafs_level, src.m_members.leafs_level);
boost::swap(m_members.root, src.m_members.root);
boost::core::invoke_swap(m_members.values_count, src.m_members.values_count);
boost::core::invoke_swap(m_members.leafs_level, src.m_members.leafs_level);
boost::core::invoke_swap(m_members.root, src.m_members.root);

// NOTE: if propagate is true for std allocators on darwin 4.2.1, glibc++
// (allocators stored as base classes of members_holder)
Expand Down Expand Up @@ -795,9 +796,9 @@ class rtree
*/
void swap(rtree & other)
{
boost::swap(m_members.indexable_getter(), other.m_members.indexable_getter());
boost::swap(m_members.equal_to(), other.m_members.equal_to());
boost::swap(m_members.parameters(), other.m_members.parameters());
boost::core::invoke_swap(m_members.indexable_getter(), other.m_members.indexable_getter());
boost::core::invoke_swap(m_members.equal_to(), other.m_members.equal_to());
boost::core::invoke_swap(m_members.parameters(), other.m_members.parameters());

// NOTE: if propagate is true for std allocators on darwin 4.2.1, glibc++
// (allocators stored as base classes of members_holder)
Expand All @@ -808,9 +809,9 @@ class rtree
> propagate;
detail::swap_cond(m_members.allocators(), other.m_members.allocators(), propagate());

boost::swap(m_members.values_count, other.m_members.values_count);
boost::swap(m_members.leafs_level, other.m_members.leafs_level);
boost::swap(m_members.root, other.m_members.root);
boost::core::invoke_swap(m_members.values_count, other.m_members.values_count);
boost::core::invoke_swap(m_members.leafs_level, other.m_members.leafs_level);
boost::core::invoke_swap(m_members.root, other.m_members.root);
}

/*!
Expand Down
1 change: 1 addition & 0 deletions include/boost/geometry/util/series_expansion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#ifndef BOOST_GEOMETRY_UTIL_SERIES_EXPANSION_HPP
#define BOOST_GEOMETRY_UTIL_SERIES_EXPANSION_HPP

#include <boost/array.hpp>
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/util/math.hpp>

Expand Down
9 changes: 8 additions & 1 deletion index/test/rtree/exceptions/test_throwing_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
#define BOOST_GEOMETRY_INDEX_TEST_RTREE_THROWING_NODE_HPP

#include <rtree/exceptions/test_throwing.hpp>
#include <boost/core/invoke_swap.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/static_visitor.hpp>
#include <exception>
#include <stddef.h>

struct throwing_nodes_stats
{
Expand Down Expand Up @@ -235,7 +242,7 @@ class allocators<Allocator, Value, Parameters, Box, node_throwing_static_tag>

void swap(allocators & a)
{
boost::swap(node_allocator(), a.node_allocator());
boost::core::invoke_swap(node_allocator(), a.node_allocator());
}

bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
Expand Down
Loading