From 3e92bdebb111a6a74eefde9fdb6cd57523798436 Mon Sep 17 00:00:00 2001 From: leha-bot Date: Thu, 20 Jul 2023 16:22:04 +0300 Subject: [PATCH] Drop Boost.Array,TypeTraits and StaticAssert In favour of std:: and C++11 core counterparts. --- example/assert_handler.cpp | 4 ++-- example/terminate_handler.cpp | 4 ++-- example/throwing_st.cpp | 4 ++-- example/user_config.cpp | 4 ++-- include/boost/stacktrace/detail/to_dec_array.hpp | 7 ++++--- include/boost/stacktrace/detail/to_hex_array.hpp | 16 +++++++--------- .../boost/stacktrace/detail/void_ptr_cast.hpp | 9 ++++----- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/example/assert_handler.cpp b/example/assert_handler.cpp index 24dc67c..d75dc0f 100644 --- a/example/assert_handler.cpp +++ b/example/assert_handler.cpp @@ -6,13 +6,13 @@ #define BOOST_ENABLE_ASSERT_HANDLER +#include // std::array #include // std::exit -#include BOOST_NOINLINE void foo(int i); BOOST_NOINLINE void bar(int i); BOOST_NOINLINE void bar(int i) { - boost::array a = {{101, 100, 123, 23, 32}}; + std::array a = {{101, 100, 123, 23, 32}}; if (i >= 0) { foo(a[i]); } else { diff --git a/example/terminate_handler.cpp b/example/terminate_handler.cpp index 3e75cda..081daf9 100644 --- a/example/terminate_handler.cpp +++ b/example/terminate_handler.cpp @@ -4,12 +4,12 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include +#include BOOST_NOINLINE void foo(int i); BOOST_NOINLINE void bar(int i); BOOST_NOINLINE void bar(int i) { - boost::array a = {{-1, -231, -123, -23, -32}}; + std::array a = {{-1, -231, -123, -23, -32}}; if (i >= 0) { foo(a[i]); } else { diff --git a/example/throwing_st.cpp b/example/throwing_st.cpp index 046a26c..76dd317 100644 --- a/example/throwing_st.cpp +++ b/example/throwing_st.cpp @@ -41,9 +41,9 @@ BOOST_NOINLINE void oops(int i) { std::exit(1); } -#include +#include BOOST_NOINLINE void bar(int i) { - boost::array a = {{0, 0, 0, 0, 0}}; + std::array a = {{0, 0, 0, 0, 0}}; if (i < 5) { if (i >= 0) { foo(a[i]); diff --git a/example/user_config.cpp b/example/user_config.cpp index cb80a58..92e73c0 100644 --- a/example/user_config.cpp +++ b/example/user_config.cpp @@ -6,7 +6,7 @@ #define BOOST_USER_CONFIG -#include +#include #include // std::set_terminate, std::abort #include #include // std::cerr @@ -14,7 +14,7 @@ BOOST_NOINLINE void foo(int i); BOOST_NOINLINE void bar(int i); BOOST_NOINLINE void bar(int i) { - boost::array a = {{-1, -231, -123, -23, -32}}; + std::array a = {{-1, -231, -123, -23, -32}}; if (i >= 0) { foo(a[i]); } else { diff --git a/include/boost/stacktrace/detail/to_dec_array.hpp b/include/boost/stacktrace/detail/to_dec_array.hpp index 04f0821..8d16ebc 100644 --- a/include/boost/stacktrace/detail/to_dec_array.hpp +++ b/include/boost/stacktrace/detail/to_dec_array.hpp @@ -12,13 +12,14 @@ # pragma once #endif -#include +#include +#include // std::size_t namespace boost { namespace stacktrace { namespace detail { // We do not use boost::lexical_cast in this function to reduce module dependencies -inline boost::array to_dec_array(std::size_t value) noexcept { - boost::array ret; +inline std::array to_dec_array(std::size_t value) noexcept { + std::array ret; if (!value) { ret[0] = '0'; ret[1] = '\0'; diff --git a/include/boost/stacktrace/detail/to_hex_array.hpp b/include/boost/stacktrace/detail/to_hex_array.hpp index c8c195f..a50de40 100644 --- a/include/boost/stacktrace/detail/to_hex_array.hpp +++ b/include/boost/stacktrace/detail/to_hex_array.hpp @@ -12,20 +12,18 @@ # pragma once #endif -#include -#include -#include -#include +#include +#include namespace boost { namespace stacktrace { namespace detail { BOOST_STATIC_CONSTEXPR char to_hex_array_bytes[] = "0123456789ABCDEF"; template -inline boost::array to_hex_array(T addr) noexcept { - boost::array ret = {"0x"}; +inline std::array to_hex_array(T addr) noexcept { + std::array ret = {"0x"}; ret.back() = '\0'; - BOOST_STATIC_ASSERT_MSG(!boost::is_pointer::value, ""); + static_assert(!std::is_pointer::value, ""); const std::size_t s = sizeof(T); @@ -43,9 +41,9 @@ inline boost::array to_hex_array(T addr) noexce return ret; } -inline boost::array to_hex_array(const void* addr) noexcept { +inline std::array to_hex_array(const void* addr) noexcept { return to_hex_array( - reinterpret_cast< boost::make_unsigned::type >(addr) + reinterpret_cast< std::make_unsigned::type >(addr) ); } diff --git a/include/boost/stacktrace/detail/void_ptr_cast.hpp b/include/boost/stacktrace/detail/void_ptr_cast.hpp index 1a70313..484c102 100644 --- a/include/boost/stacktrace/detail/void_ptr_cast.hpp +++ b/include/boost/stacktrace/detail/void_ptr_cast.hpp @@ -13,8 +13,7 @@ # pragma once #endif -#include -#include +#include #if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301) # pragma GCC system_header @@ -26,12 +25,12 @@ namespace boost { namespace stacktrace { namespace detail { // This functionsuppress the warnings and ensures that such casts are safe. template To void_ptr_cast(From* v) noexcept { - BOOST_STATIC_ASSERT_MSG( - boost::is_pointer::value, + static_assert( + std::is_pointer::value, "`void_ptr_cast` function must be used only for casting to or from void pointers." ); - BOOST_STATIC_ASSERT_MSG( + static_assert( sizeof(From*) == sizeof(To), "Pointer to function and pointer to object differ in size on your platform." );