Skip to content

Refactor/reduce misc boost dependencies#1459

Open
tinko92 wants to merge 9 commits intoboostorg:developfrom
tinko92:refactor/reduce-misc-boost-dependencies
Open

Refactor/reduce misc boost dependencies#1459
tinko92 wants to merge 9 commits intoboostorg:developfrom
tinko92:refactor/reduce-misc-boost-dependencies

Conversation

@tinko92
Copy link
Copy Markdown
Collaborator

@tinko92 tinko92 commented Apr 25, 2026

This PR removes a number of dependencies to other Boost libraries. It is more narrow in scope than the prior #1425 (closed it in favour of this) and cleanly (I hope) separates changes to extensions from changes that go into a release. I tried to limit it to headers and features that have one to one replacements to make it more reviewable. I will add comments where I deviate from that.
Varray was intentionally untouched because I propose to remove it in #1458 and don't want to create merge conflicts. This PR is intended to come after that, if the remove does not happen, I can update this one.

BOOST_STATIC_ASSERT((diff > 0)); // make sure we've the right assumption. GCC does not accept this here.
#endif
static constexpr int diff = 'a' - 'A';
static_assert(diff > 0, "Character set must be case-sensitive.");
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Does not seem to cause issues with GCC anymore.

std::is_floating_point<T>::value,
double,
std::conditional<std::is_integral<T>::value, int, std::string>::type
>::type;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is intentionally more narrow than promote because DBFFieldType has implementations for exactly double, int and string.


template <>
struct DBFWriteAttribute<char*> : DBFWriteAttribute<std::string> {};

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not needed due to more narrowly implemented promotion.

#ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP

#include <algorithm>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For std::max. Seems to have been included indirectly through one of the removed includes, broke in testing.

template <typename Coeffs>
constexpr size_t static_size =
decltype(array_base_size_helper(static_cast<Coeffs*>(nullptr)))::value;

Copy link
Copy Markdown
Collaborator Author

@tinko92 tinko92 Apr 25, 2026

Choose a reason for hiding this comment

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

This is slightly unfortunate extra complexity from std::array not having a static_size method that would be inherited but I hope acceptable.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

recheck_commandstale_pending_rereview のときだけ組み立てるように修正しました。text 出力と JSON 出力の条件を揃えています。

}
private:
boost::aligned_storage<sizeof(T), boost::alignment_of<T>::value> m_storage;
alignas(T) unsigned char m_storage[sizeof(T)];
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Chosen over the 1-to-1 STL equivalent std::aligned_storage because that has been deprecated


#include <cassert>
#include <cmath>
#include <cstddef>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For size_t used later in this file. Broke in testing, so must have been previously indirectly included through one of the removed includes.

Comment thread test/core/visit.cpp
BOOST_CHECK(bg::util::is_point<decltype(g)>::value);
BOOST_STATIC_ASSERT(! std::is_const<decltype(g)>::value);
static_assert(! std::is_const<decltype(g)>::value,
"Copy of mutable must be visited as mutable.");
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

C++17 brings static_assert(bool) without message. This adds a little wordiness but I think that is not necessarily bad, some of the cases below were not immediately obvious to me.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces Boost.Geometry’s transitive dependencies by replacing assorted Boost utilities (e.g., BOOST_STATIC_ASSERT, Boost.TypeTraits, boost::addressof, boost::array, boost::noncopyable, Boost.Cstdint) with equivalent C++14 standard library facilities across headers, tests, examples, and docs.

Changes:

  • Replace Boost compile-time assertions/type-traits with static_assert and <type_traits> equivalents.
  • Replace boost::addressof/boost::array/Boost.Cstdint with std::addressof/std::array/<cstdint> and adjust includes accordingly.
  • Remove some Boost.Build declared dependencies (notably boost_type_traits) and modernize related docs/examples.

Reviewed changes

Copilot reviewed 116 out of 116 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
test/views/random_access_view.cpp Replace BOOST_STATIC_ASSERT with static_assert and add messages.
test/util/transform_variant.cpp Replace boost::add_pointer with std::add_pointer; adjust includes.
test/util/is_implemented.cpp Remove Boost.TypeTraits include.
test/util/compress_variant.cpp Replace boost::is_same with std::is_same; adjust includes.
test/strategies/segment_intersection_sph.hpp Replace boost::is_same with std::is_same; add <type_traits>.
test/strategies/pythagoras.cpp Replace boost::is_same with std::is_same; add <type_traits>.
test/io/wkt/wkt.cpp Replace boost::is_same with std::is_same.
test/core/visit.cpp Replace BOOST_STATIC_ASSERT with static_assert and messages.
test/algorithms/relate/relate_linear_areal.cpp Replace boost::is_same with std::is_same; add <type_traits>.
test/algorithms/overlay/get_turns_linear_linear.cpp Replace boost::is_same with std::is_same; add <type_traits>.
test/algorithms/overlay/copy_segment_point.cpp Replace boost::array with std::array; add <array>.
test/algorithms/is_valid.cpp Replace boost::is_floating_point with std::is_floating_point; add <type_traits>.
test/algorithms/distance/distance.cpp Replace boost::array with std::array and update traits specialization.
test/algorithms/detail/visit.cpp Replace BOOST_STATIC_ASSERT with static_assert and messages.
index/test/rtree/rtree_values.cpp Replace Boost type traits/addressof with std equivalents; adjust includes.
include/boost/geometry/views/enumerate_view.hpp Add missing <algorithm> include for std::max.
include/boost/geometry/views/detail/geometry_collection_view.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/views/detail/boundary_view/implementation.hpp Replace boost::addressof with std::addressof.
include/boost/geometry/util/series_expansion.hpp Switch boost::array-based coeff containers to std::array; update size handling.
include/boost/geometry/util/range.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/util/calculation_type.hpp Replace BOOST_STATIC_ASSERT with static_assert; remove Boost.StaticAssert include.
include/boost/geometry/strategies/buffer.hpp Replace <cstdint> with <cstddef> for std::size_t usage.
include/boost/geometry/srs/transformation.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/srs/spheroid.hpp Replace BOOST_STATIC_ASSERT with static_assert; remove Boost.StaticAssert include.
include/boost/geometry/srs/sphere.hpp Replace BOOST_STATIC_ASSERT with static_assert; remove Boost.StaticAssert include.
include/boost/geometry/srs/projections/str_cast.hpp Replace boost::remove_cv with std::remove_cv; include <type_traits>.
include/boost/geometry/srs/projections/impl/pj_param.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/srs/projections/impl/pj_gridinfo.hpp Replace Boost integer typedefs with <cstdint> types; modernize asserts.
include/boost/geometry/srs/projections/impl/pj_auth.hpp Add <cstddef> include.
include/boost/geometry/srs/projections/impl/pj_apply_gridshift.hpp Replace Boost integer types/addressof with std equivalents; add headers.
include/boost/geometry/srs/projections/impl/dms_parser.hpp Replace BOOST_STATIC_ASSERT with static_assert; simplify diff constant.
include/boost/geometry/srs/projections/grids.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/io/wkt/read.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/io/svg/svg_mapper.hpp Remove boost::noncopyable; explicitly delete copy constructor.
include/boost/geometry/index/detail/serialization.hpp Replace Boost aligned storage/type traits and addressof usage with std equivalents.
include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp Replace boost::addressof with std::addressof.
include/boost/geometry/index/detail/rtree/visitors/iterator.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/index/detail/rtree/utilities/print.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp Replace BOOST_STATIC_ASSERT with static_assert; remove static_assert header include.
include/boost/geometry/index/detail/rtree/query_iterators.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/index/detail/rtree/pack_create.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/index/detail/rtree/iterators.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/index/detail/algorithms/sum_for_indexable.hpp Add <cstddef> include for std::size_t.
include/boost/geometry/index/detail/algorithms/smallest_for_indexable.hpp Add <cstddef> include for std::size_t.
include/boost/geometry/index/detail/algorithms/segment_intersection.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/index/detail/algorithms/margin.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/index/detail/algorithms/content.hpp Add <algorithm> and replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/geometries/pointing_segment.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/geometries/point.hpp Replace BOOST_STATIC_ASSERT with static_assert; remove Boost.StaticAssert include.
include/boost/geometry/geometries/concepts/polyhedral_surface_concept.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp Replace Boost type traits with std equivalents; add <type_traits>.
include/boost/geometry/geometries/adapted/boost_fusion.hpp Replace boost::is_same with std::is_same; remove Boost.TypeTraits include.
include/boost/geometry/extensions/nsphere/index/detail/algorithms/margin.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/nsphere/index/detail/algorithms/content.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/nsphere/core/radius.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/multi/gis/io/wkb/detail/writer.hpp Remove Boost.StaticAssert include.
include/boost/geometry/extensions/multi/gis/io/wkb/detail/parser.hpp Replace Boost integer types with <cstdint> equivalents.
include/boost/geometry/extensions/gis/io/wkb/write_wkb.hpp Replace BOOST_STATIC_ASSERT with static_assert; remove Boost.StaticAssert include.
include/boost/geometry/extensions/gis/io/wkb/utility.hpp Replace Boost integer/static assert with std equivalents; include <cstdint>.
include/boost/geometry/extensions/gis/io/wkb/read_wkb.hpp Replace BOOST_STATIC_ASSERT with static_assert; include <cstdint>.
include/boost/geometry/extensions/gis/io/wkb/detail/writer.hpp Remove Boost.StaticAssert include.
include/boost/geometry/extensions/gis/io/wkb/detail/parser.hpp Replace Boost integer/static assert usage with std equivalents; include <cstdint>.
include/boost/geometry/extensions/gis/io/wkb/detail/ogc.hpp Replace Boost integer types with <cstdint> types.
include/boost/geometry/extensions/gis/io/wkb/detail/endian.hpp Replace Boost integer/static assert usage with std equivalents; include <cstdint>.
include/boost/geometry/extensions/gis/io/shapelib/shape_reader.hpp Remove boost::noncopyable; add deleted copy constructor.
include/boost/geometry/extensions/gis/io/shapelib/shape_creator.hpp Remove boost::noncopyable/boost::promote; add promote_t and delete copy ctor.
include/boost/geometry/extensions/gis/io/shapelib/dbf_write_attribute.hpp Remove C-string specializations for DBF write helper.
include/boost/geometry/extensions/gis/io/shapefile/read.hpp Replace Boost integer/static assert usage with std equivalents; include <cstdint>.
include/boost/geometry/extensions/algorithms/distance_info.hpp Remove Boost.StaticAssert include.
include/boost/geometry/extensions/algebra/geometries/vector.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/algebra/geometries/rotation_quaternion.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/algebra/geometries/rotation_matrix.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/algebra/geometries/quaternion.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/algebra/geometries/matrix.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/extensions/algebra/algorithms/detail.hpp Replace BOOST_STATIC_ASSERT with static_assert; remove Boost.StaticAssert include.
include/boost/geometry/core/static_assert.hpp Remove Boost.StaticAssert include.
include/boost/geometry/core/radius.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/core/coordinate_dimension.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/simplify.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/turns/compare_turns.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/detail/touches/implementation.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/detail/sections/sectionalize.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/detail/relate/turns.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/detail/relate/result.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/detail/relate/linear_linear.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/relate/linear_areal.hpp Replace BOOST_STATIC_ASSERT with static_assert; replace boost::addressof; include <memory>.
include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/relate/areal_areal.hpp Replace BOOST_STATIC_ASSERT with static_assert; replace boost::addressof; include <memory>.
include/boost/geometry/algorithms/detail/point_on_border.hpp Remove Boost.StaticAssert include.
include/boost/geometry/algorithms/detail/overlay/less_by_segment_ratio.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/overlay/get_turn_info_for_endpoint.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp Replace BOOST_STATIC_ASSERT with static_assert.
include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp Remove Boost.StaticAssert include.
include/boost/geometry/algorithms/detail/is_valid/complement_graph.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/for_each_range.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/distance/segment_to_segment.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/closest_points/segment_to_segment.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/centroid/translating_transformer.hpp Replace boost::addressof with std::addressof; include <memory>.
include/boost/geometry/algorithms/detail/buffer/piece_border.hpp Replace boost::addressof with std::addressof; include <memory>.
extensions/test/gis/io/wkb/read_wkb.cpp Replace Boost uint8 type with std::uint8_t; include <cstdint>.
extensions/test/algorithms/distance_info.cpp Replace boost::is_same with std::is_same; include <type_traits>.
extensions/example/experimental/geometry_of.cpp Replace Boost reference trait with std trait; include <type_traits>.
example/c08_custom_non_std_example.cpp Replace boost::is_const with std::is_const; include <type_traits>.
example/c06_custom_polygon_example.cpp Replace boost::array with std::array; include <array>.
example/c04_b_custom_triangle_example.cpp Replace boost::array with std::array; include <array>.
example/c04_a_custom_triangle_example.cpp Replace boost::array with std::array; include <array>.
doc/src/examples/core/rings.cpp Replace boost::is_same with std::is_same; include <type_traits>.
doc/src/examples/core/ring_type.cpp Replace boost::is_same with std::is_same; include <type_traits>.
doc/src/docutils/tools/support_status/support_status.cpp Replace boost::is_base_of with std::is_base_of; include <type_traits>.
doc/doxy/Doxyfile Remove BOOST_STATIC_ASSERT from Doxygen predefined list.
doc/design_rationale.qbk Replace BOOST_STATIC_ASSERT with static_assert in docs.
build.jam Remove boost_type_traits from declared Boost.Build dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/boost/geometry/extensions/gis/io/shapelib/shape_creator.hpp
Comment thread include/boost/geometry/extensions/gis/io/shapelib/shape_creator.hpp
Comment thread test/algorithms/detail/visit.cpp Outdated
Comment thread test/algorithms/detail/visit.cpp Outdated
Comment on lines +40 to +46
template <typename T, size_t N>
auto array_base_size_helper(std::array<T, N> const*)
-> std::integral_constant<size_t, N>;

template <typename Coeffs>
constexpr size_t static_size =
decltype(array_base_size_helper(static_cast<Coeffs*>(nullptr)))::value;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread include/boost/geometry/extensions/gis/io/shapelib/shape_reader.hpp Outdated
Comment thread test/core/visit.cpp Outdated
Comment thread include/boost/geometry/extensions/gis/io/wkb/read_wkb.hpp Outdated
Comment thread build.jam
@@ -39,7 +39,6 @@ constant boost_dependencies :
/boost/throw_exception//boost_throw_exception
/boost/tokenizer//boost_tokenizer
/boost/tuple//boost_tuple
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If #1458 is merged before this, this will be resolved.

@tinko92 tinko92 force-pushed the refactor/reduce-misc-boost-dependencies branch from 752effc to 2a099f2 Compare April 25, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants