Skip to content

Commit

Permalink
Drop Boost.Array,TypeTraits and StaticAssert
Browse files Browse the repository at this point in the history
In favour of std:: and C++11 core counterparts.
  • Loading branch information
leha-bot committed Jul 20, 2023
1 parent 8720806 commit 3e92bde
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions example/assert_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

#define BOOST_ENABLE_ASSERT_HANDLER

#include <array> // std::array
#include <cstdlib> // std::exit
#include <boost/array.hpp>
BOOST_NOINLINE void foo(int i);
BOOST_NOINLINE void bar(int i);

BOOST_NOINLINE void bar(int i) {
boost::array<int, 5> a = {{101, 100, 123, 23, 32}};
std::array<int, 5> a = {{101, 100, 123, 23, 32}};
if (i >= 0) {
foo(a[i]);
} else {
Expand Down
4 changes: 2 additions & 2 deletions example/terminate_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <boost/array.hpp>
#include <array>
BOOST_NOINLINE void foo(int i);
BOOST_NOINLINE void bar(int i);

BOOST_NOINLINE void bar(int i) {
boost::array<int, 5> a = {{-1, -231, -123, -23, -32}};
std::array<int, 5> a = {{-1, -231, -123, -23, -32}};
if (i >= 0) {
foo(a[i]);
} else {
Expand Down
4 changes: 2 additions & 2 deletions example/throwing_st.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ BOOST_NOINLINE void oops(int i) {
std::exit(1);
}

#include <boost/array.hpp>
#include <array>
BOOST_NOINLINE void bar(int i) {
boost::array<int, 5> a = {{0, 0, 0, 0, 0}};
std::array<int, 5> a = {{0, 0, 0, 0, 0}};
if (i < 5) {
if (i >= 0) {
foo(a[i]);
Expand Down
4 changes: 2 additions & 2 deletions example/user_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

#define BOOST_USER_CONFIG <libs/stacktrace/example/user_config.hpp>

#include <boost/array.hpp>
#include <array>
#include <exception> // std::set_terminate, std::abort
#include <boost/stacktrace.hpp>
#include <iostream> // std::cerr
BOOST_NOINLINE void foo(int i);
BOOST_NOINLINE void bar(int i);

BOOST_NOINLINE void bar(int i) {
boost::array<int, 5> a = {{-1, -231, -123, -23, -32}};
std::array<int, 5> a = {{-1, -231, -123, -23, -32}};
if (i >= 0) {
foo(a[i]);
} else {
Expand Down
7 changes: 4 additions & 3 deletions include/boost/stacktrace/detail/to_dec_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
# pragma once
#endif

#include <boost/array.hpp>
#include <array>
#include <cstddef> // 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<char, 40> to_dec_array(std::size_t value) noexcept {
boost::array<char, 40> ret;
inline std::array<char, 40> to_dec_array(std::size_t value) noexcept {
std::array<char, 40> ret;
if (!value) {
ret[0] = '0';
ret[1] = '\0';
Expand Down
16 changes: 7 additions & 9 deletions include/boost/stacktrace/detail/to_hex_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
# pragma once
#endif

#include <boost/array.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <array>
#include <type_traits>

namespace boost { namespace stacktrace { namespace detail {

BOOST_STATIC_CONSTEXPR char to_hex_array_bytes[] = "0123456789ABCDEF";

template <class T>
inline boost::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(T addr) noexcept {
boost::array<char, 2 + sizeof(void*) * 2 + 1> ret = {"0x"};
inline std::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(T addr) noexcept {
std::array<char, 2 + sizeof(void*) * 2 + 1> ret = {"0x"};
ret.back() = '\0';
BOOST_STATIC_ASSERT_MSG(!boost::is_pointer<T>::value, "");
static_assert(!std::is_pointer<T>::value, "");

const std::size_t s = sizeof(T);

Expand All @@ -43,9 +41,9 @@ inline boost::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(T addr) noexce
return ret;
}

inline boost::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(const void* addr) noexcept {
inline std::array<char, 2 + sizeof(void*) * 2 + 1> to_hex_array(const void* addr) noexcept {
return to_hex_array(
reinterpret_cast< boost::make_unsigned<std::ptrdiff_t>::type >(addr)
reinterpret_cast< std::make_unsigned<std::ptrdiff_t>::type >(addr)
);
}

Expand Down
9 changes: 4 additions & 5 deletions include/boost/stacktrace/detail/void_ptr_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# pragma once
#endif

#include <boost/static_assert.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <type_traits>

#if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301)
# pragma GCC system_header
Expand All @@ -26,12 +25,12 @@ namespace boost { namespace stacktrace { namespace detail {
// This functionsuppress the warnings and ensures that such casts are safe.
template <class To, class From>
To void_ptr_cast(From* v) noexcept {
BOOST_STATIC_ASSERT_MSG(
boost::is_pointer<To>::value,
static_assert(
std::is_pointer<To>::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."
);
Expand Down

0 comments on commit 3e92bde

Please sign in to comment.