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

Replace boost type_traits with stl type_traits. #1373

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ target_link_libraries(boost_geometry
Boost::throw_exception
Boost::tokenizer
Boost::tuple
Boost::type_traits
Boost::utility
Boost::variant
)
Expand Down
1 change: 0 additions & 1 deletion build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ constant boost_dependencies :
/boost/throw_exception//boost_throw_exception
/boost/tokenizer//boost_tokenizer
/boost/tuple//boost_tuple
/boost/type_traits//boost_type_traits
/boost/variant//boost_variant
/boost/variant2//boost_variant2 ;

Expand Down
6 changes: 3 additions & 3 deletions doc/src/docutils/tools/support_status/support_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <type_traits>

#include <boost/mpl/for_each.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/is_base_of.hpp>

#define BOOST_GEOMETRY_IMPLEMENTATION_STATUS_BUILD true
#include <boost/geometry/core/cs.hpp>
Expand Down Expand Up @@ -145,7 +145,7 @@ struct do_unary_test

void operator()()
{
if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G> >::type::value)
if (std::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G> >::type::value)
{
m_outputter.nyi();
}
Expand All @@ -167,7 +167,7 @@ struct do_binary_test
template <typename G1>
void operator()(G1)
{
if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G1, G2> >::type::value)
if (std::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G1, G2> >::type::value)
{
m_outputter.nyi();
}
Expand Down
5 changes: 2 additions & 3 deletions extensions/example/experimental/geometry_of.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
#include <vector>
#include <string>
#include <iostream>

#include <type_traits>


#include <boost/proto/core.hpp>
#include <boost/proto/transform.hpp>
#include <boost/type_traits/add_reference.hpp>

#include <boost/mpl/assert.hpp>

Expand All @@ -40,7 +39,7 @@ struct append_point : proto::callable

template<typename This, typename Geometry, typename T1, typename T2>
struct result<This(Geometry, T1, T2)>
: boost::add_reference<Geometry>
: std::add_reference<Geometry>
{};

template<typename Geometry, typename T1, typename T2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


#include <boost/noncopyable.hpp>
#include <boost/type_traits/promote.hpp>

#include <boost/geometry/extensions/gis/io/shapelib/shp_read_object.hpp>

Expand Down
7 changes: 3 additions & 4 deletions include/boost/geometry/index/detail/serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_SERIALIZATION_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_SERIALIZATION_HPP

#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/aligned_storage.hpp>
#include <type_traits>

#include <boost/serialization/serialization.hpp>
#include <boost/serialization/split_member.hpp>
Expand Down Expand Up @@ -65,10 +64,10 @@ class serialization_storage
}
T * address()
{
return static_cast<T*>(m_storage.address());
return static_cast<void*>(&m_storage);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@awulkiew is this fine?

Copy link
Member

@awulkiew awulkiew Mar 5, 2025

Choose a reason for hiding this comment

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

std::aligned_storage is deprecated in C++23. AFAIR boost version is superior to the std one but I can't remember why besides the fact that it doesn't force us to cast address of the storage. A proposed replacement is something like this:

alignas(T) std::byte storage[sizeof(T)];

but it requires C++17 and would require careful testing. So I'd prefer to keep boost::aligned_storage for now.

Copy link
Member

Choose a reason for hiding this comment

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

Btw, here https://en.cppreference.com/w/cpp/types/aligned_storage the required use of std::launder is mentioned. This change can introduce some unwanted effects. I guess I strongly suggest to keep the old version. :)

}
private:
boost::aligned_storage<sizeof(T), boost::alignment_of<T>::value> m_storage;
std::aligned_storage<sizeof(T), std::alignment_of<T>::value> m_storage;
};

// TODO - save and load item_version? see: collections_load_imp and collections_save_imp
Expand Down
19 changes: 9 additions & 10 deletions include/boost/geometry/index/detail/varray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_HPP

#include <type_traits>

// TODO - REMOVE/CHANGE
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
Expand All @@ -29,9 +31,6 @@
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/iterator/iterator_concepts.hpp>

#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/aligned_storage.hpp>

#include <boost/geometry/core/static_assert.hpp>

#include <boost/geometry/index/detail/assert.hpp>
Expand Down Expand Up @@ -159,9 +158,9 @@ class varray
typename vt::size_type, std::integral_constant<std::size_t, Capacity>
);

typedef boost::aligned_storage<
typedef std::aligned_storage<
sizeof(Value[Capacity]),
boost::alignment_of<Value[Capacity]>::value
std::alignment_of<Value[Capacity]>::value
> aligned_storage_type;

template <typename V, std::size_t C>
Expand Down Expand Up @@ -1031,7 +1030,7 @@ class varray
++m_size; // update end
sv::move_backward(position, this->end() - 2, this->end() - 1); // may throw

aligned_storage<sizeof(value_type), alignment_of<value_type>::value> temp_storage;
std::aligned_storage<sizeof(value_type), std::alignment_of<value_type>::value> temp_storage;
value_type* val_p = static_cast<value_type*>(temp_storage.address());
sv::construct(dti(), val_p, std::forward<Args>(args)...); // may throw
sv::scoped_destructor<value_type> d(val_p);
Expand Down Expand Up @@ -1536,9 +1535,9 @@ class varray
namespace sv = varray_detail;
for (; first_sm != last_sm ; ++first_sm, ++first_la)
{
boost::aligned_storage<
std::aligned_storage<
sizeof(value_type),
boost::alignment_of<value_type>::value
std::alignment_of<value_type>::value
> temp_storage;
value_type* temp_ptr = reinterpret_cast<value_type*>(temp_storage.address());

Expand Down Expand Up @@ -1729,12 +1728,12 @@ class varray

pointer ptr()
{
return pointer(static_cast<Value*>(m_storage.address()));
return pointer(static_cast<void*>(&m_storage));
}

const_pointer ptr() const
{
return const_pointer(static_cast<const Value*>(m_storage.address()));
return const_pointer(static_cast<const void*>(&m_storage));
}

size_type m_size;
Expand Down
5 changes: 3 additions & 2 deletions include/boost/geometry/srs/projections/str_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
#ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_STR_CAST_HPP
#define BOOST_GEOMETRY_SRS_PROJECTIONS_STR_CAST_HPP

#include <type_traits>

#include <boost/config.hpp>
#include <boost/geometry/core/exception.hpp>
#include <boost/throw_exception.hpp>
#include <boost/type_traits/remove_cv.hpp>

namespace boost { namespace geometry
{
Expand Down Expand Up @@ -116,7 +117,7 @@ struct str_cast_traits_generic
char * str_end = (char*)(void*)str;
T res = str_cast_traits_strtox
<
typename boost::remove_cv<T>::type
typename std::remove_cv<T>::type
>::apply(str, &str_end);
if (str_end == str)
{
Expand Down
4 changes: 2 additions & 2 deletions test/util/compress_variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <type_traits>

#include <boost/test/included/test_exec_monitor.hpp>
#include <boost/geometry/util/compress_variant.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/variant/variant.hpp>


Expand All @@ -43,7 +43,7 @@ template <typename Variant, typename ExpectedType>
void test_single_type_result()
{
BOOST_MPL_ASSERT((
boost::is_same<
std::is_same<
typename boost::geometry::compress_variant<Variant>::type,
ExpectedType
>
Expand Down
2 changes: 1 addition & 1 deletion test/util/is_implemented.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <type_traits>

#include <geometry_test_common.hpp>

Expand All @@ -23,7 +24,6 @@

#include <boost/geometry/util/is_implemented.hpp>

#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/bool.hpp>

Expand Down
1 change: 0 additions & 1 deletion test/util/rational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ template <typename T>
void test_bounds()
{
using coordinate_t = boost::rational<T>;
using point_t = bg::model::point<coordinate_t, 2, bg::cs::cartesian>;

auto const lowest = bg::util::bounds<coordinate_t>::lowest();
auto const highest = bg::util::bounds<coordinate_t>::highest();
Expand Down
8 changes: 4 additions & 4 deletions test/util/transform_variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <type_traits>

#include <boost/test/included/test_exec_monitor.hpp>
#include <boost/geometry/util/transform_variant.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits.hpp>
#include <boost/variant/variant.hpp>

using boost::mpl::placeholders::_;
Expand All @@ -42,23 +42,23 @@ int test_main(int, char* [])
// Transform Variant to Variant
typedef boost::geometry::transform_variant<
boost::variant<int, float, long>,
boost::add_pointer<_>
std::add_pointer<_>
>::type transformed1;

check<boost::mpl::vector<int*, float*, long*> >(transformed1());

// Transform Sequence to Variant (without inserter)
typedef boost::geometry::transform_variant<
boost::mpl::vector<int, float, long>,
boost::add_pointer<_>
std::add_pointer<_>
>::type transformed2;

check<boost::mpl::vector<int*, float*, long*> >(transformed2());

// Transform Sequence to Variant (with inserter)
typedef boost::geometry::transform_variant<
boost::mpl::vector<int, float, long>,
boost::add_pointer<_>,
std::add_pointer<_>,
boost::mpl::back_inserter<boost::mpl::vector0<> >
>::type transformed3;

Expand Down
Loading