From 949c15ebfec09d2c48424e50d4ab52b8d78e2d6e Mon Sep 17 00:00:00 2001 From: Arnaud Becheler <8360330+Becheler@users.noreply.github.com> Date: Thu, 24 Sep 2026 16:50:03 +0200 Subject: [PATCH] refactor: drop boost.smart_ptr dependency --- CMakeLists.txt | 1 - build.jam | 1 - .../property_map/dynamic_property_map.hpp | 23 ++++++++++--------- .../shared_array_property_map.hpp | 9 ++++---- .../property_map/vector_property_map.hpp | 9 ++++---- test/dynamic_properties_test.cpp | 7 +++--- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fe56d0..c96380b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ target_link_libraries(boost_property_map Boost::iterator Boost::lexical_cast Boost::mpl - Boost::smart_ptr Boost::throw_exception Boost::type_traits Boost::utility diff --git a/build.jam b/build.jam index c624826..bbd9292 100644 --- a/build.jam +++ b/build.jam @@ -15,7 +15,6 @@ constant boost_dependencies : /boost/iterator//boost_iterator /boost/lexical_cast//boost_lexical_cast /boost/mpl//boost_mpl - /boost/smart_ptr//boost_smart_ptr /boost/throw_exception//boost_throw_exception /boost/type_index//boost_type_index /boost/type_traits//boost_type_traits diff --git a/include/boost/property_map/dynamic_property_map.hpp b/include/boost/property_map/dynamic_property_map.hpp index 336f000..4c04cec 100644 --- a/include/boost/property_map/dynamic_property_map.hpp +++ b/include/boost/property_map/dynamic_property_map.hpp @@ -2,6 +2,7 @@ #define BOOST_PROPERTY_MAP_DYNAMIC_PROPERTY_MAP_HPP // Copyright 2004-5 The Trustees of Indiana University. +// Copyright 2026, Arnaud Becheler // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -27,9 +28,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -209,9 +210,9 @@ class dynamic_property_map_adaptor : public dynamic_property_map // struct dynamic_properties { - typedef std::multimap > + typedef std::multimap > property_maps_type; - typedef boost::function3, + typedef boost::function3, const std::string&, const boost::any&, const boost::any&> generate_fn_type; @@ -229,9 +230,9 @@ struct dynamic_properties dynamic_properties& property(const std::string& name, PropertyMap property_map_) { - boost::shared_ptr pm( - boost::static_pointer_cast( - boost::make_shared >(property_map_))); + std::shared_ptr pm( + std::static_pointer_cast( + std::make_shared >(property_map_))); property_maps.insert(property_maps_type::value_type(name, pm)); return *this; @@ -258,13 +259,13 @@ struct dynamic_properties { return property_maps.lower_bound(name); } void - insert(const std::string& name, boost::shared_ptr pm) + insert(const std::string& name, std::shared_ptr pm) { property_maps.insert(property_maps_type::value_type(name, pm)); } template - boost::shared_ptr + std::shared_ptr generate(const std::string& name, const Key& key, const Value& value) { if(!generate_fn) { @@ -292,7 +293,7 @@ put(const std::string& name, dynamic_properties& dp, const Key& key, } } - boost::shared_ptr new_map = dp.generate(name, key, value); + std::shared_ptr new_map = dp.generate(name, key, value); if (new_map.get()) { new_map->put(key, value); dp.insert(name, new_map); @@ -343,11 +344,11 @@ get(const std::string& name, const dynamic_properties& dp, const Key& key) // The easy way to ignore properties. inline -boost::shared_ptr +std::shared_ptr ignore_other_properties(const std::string&, const boost::any&, const boost::any&) { - return boost::shared_ptr(); + return std::shared_ptr(); } } // namespace boost diff --git a/include/boost/property_map/shared_array_property_map.hpp b/include/boost/property_map/shared_array_property_map.hpp index 8056d95..915faff 100644 --- a/include/boost/property_map/shared_array_property_map.hpp +++ b/include/boost/property_map/shared_array_property_map.hpp @@ -1,5 +1,6 @@ // Copyright (C) 2009 Trustees of Indiana University // Authors: Jeremiah Willcock, Andrew Lumsdaine +// Copyright 2026, Arnaud Becheler // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -10,8 +11,8 @@ #ifndef BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP #define BOOST_SHARED_ARRAY_PROPERTY_MAP_HPP -#include #include +#include namespace boost { @@ -30,14 +31,14 @@ class shared_array_property_map explicit inline shared_array_property_map( size_t n, const IndexMap& _id = IndexMap()) - : data(new T[n]), index(_id) {} + : data(new T[n], std::default_delete()), index(_id) {} inline T& operator[](key_type v) const { - return data[get(index, v)]; + return data.get()[get(index, v)]; } private: - boost::shared_array data; + std::shared_ptr data; IndexMap index; }; diff --git a/include/boost/property_map/vector_property_map.hpp b/include/boost/property_map/vector_property_map.hpp index baf615f..5a37f23 100644 --- a/include/boost/property_map/vector_property_map.hpp +++ b/include/boost/property_map/vector_property_map.hpp @@ -1,4 +1,5 @@ // Copyright (C) Vladimir Prus 2003. +// Copyright 2026, Arnaud Becheler // Distributed under 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) @@ -11,8 +12,8 @@ #define BOOST_PROPERTY_MAP_VECTOR_PROPERTY_MAP_HPP #include -#include #include +#include #include namespace boost { @@ -31,12 +32,12 @@ namespace boost { typedef boost::lvalue_property_map_tag category; vector_property_map(const IndexMap& index = IndexMap()) - : store(new std::vector()), index(index) + : store(std::make_shared >()), index(index) {} vector_property_map(unsigned initial_size, const IndexMap& index = IndexMap()) - : store(new std::vector(initial_size)), index(index) + : store(std::make_shared >(initial_size)), index(index) {} typename std::vector::iterator storage_begin() @@ -81,7 +82,7 @@ namespace boost { // store pointer to data, because if copy of property map resizes // the vector, the pointer to data will be invalidated. // I wonder if class 'pmap_ref' is simply needed. - shared_ptr< std::vector > store; + std::shared_ptr< std::vector > store; IndexMap index; }; diff --git a/test/dynamic_properties_test.cpp b/test/dynamic_properties_test.cpp index 779d31a..da5520c 100644 --- a/test/dynamic_properties_test.cpp +++ b/test/dynamic_properties_test.cpp @@ -1,5 +1,6 @@ // Copyright 2005 The Trustees of Indiana University. +// Copyright 2026, Arnaud Becheler // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -18,17 +19,15 @@ #endif #include -#include #include #include #include -#include #include #include // generate a dynamic_property_map that maps strings to strings // WARNING: This code uses library internals. For testing purposes only! -boost::shared_ptr +std::shared_ptr string2string_gen(const std::string&, const boost::any&, const boost::any&) { @@ -41,7 +40,7 @@ string2string_gen(const std::string&, std::shared_ptr mymap = std::make_shared(); adaptor_t* adaptor = new adaptor_t(property_t(*mymap)); - return boost::shared_ptr( + return std::shared_ptr( adaptor, [mymap](boost::dynamic_property_map* p) { delete p; }); }