Skip to content

Commit

Permalink
fix: remove Boost (port BSTObjectArena.h from CommonLibF4) (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee authored Jul 24, 2024
1 parent 0801c7a commit 107987c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
12 changes: 3 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ endif()
option(SFSE_SUPPORT_XBYAK "Enables trampoline support for Xbyak." OFF)
option(SFSE_BUILD_TESTS "Builds the tests." OFF)

set(Boost_USE_STATIC_RUNTIME OFF CACHE BOOL "")

# info
project(
CommonLibSF
Expand All @@ -24,7 +22,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)
set(CMAKE_OPTIMIZE_DEPENDENCIES ON)
set(Boost_USE_STATIC_LIBS ON)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

Expand All @@ -37,11 +34,10 @@ endif()

# dependencies
find_package(spdlog CONFIG REQUIRED)
find_package(boost MODULE REQUIRED)

file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/include/*"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*"
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/include/*"
"${CMAKE_CURRENT_SOURCE_DIR}/src/*"
)

source_group(
Expand All @@ -53,7 +49,6 @@ function(configure_target TARGET_NAME)
target_compile_definitions(
${TARGET_NAME}
PUBLIC
BOOST_STL_INTERFACES_DISABLE_CONCEPTS
WINVER=0x0A00 # windows 10, minimum supported version by starfield
_WIN32_WINNT=0x0A00
"$<$<BOOL:${SFSE_SUPPORT_XBYAK}>:SFSE_SUPPORT_XBYAK=1>"
Expand Down Expand Up @@ -115,7 +110,6 @@ function(configure_target TARGET_NAME)
target_link_libraries(
${TARGET_NAME}
PUBLIC
Boost::headers
spdlog::spdlog
Version.lib
Dbghelp.lib
Expand Down
48 changes: 26 additions & 22 deletions include/RE/B/BSTObjectArena.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "RE/M/MemoryManager.h"
#include <boost/stl_interfaces/iterator_interface.hpp>

namespace RE
{
Expand Down Expand Up @@ -58,32 +57,20 @@ namespace RE

private:
template <class U>
class iterator_base :
public boost::stl_interfaces::iterator_interface<
iterator_base<U>,
std::forward_iterator_tag,
U>
class iterator_base
{
private:
using super =
boost::stl_interfaces::iterator_interface<
iterator_base<U>,
std::forward_iterator_tag,
U>;

public:
using difference_type = typename super::difference_type;
using value_type = typename super::value_type;
using pointer = typename super::pointer;
using reference = typename super::reference;
using iterator_category = typename super::iterator_category;
using difference_type = std::ptrdiff_t;
using value_type = std::remove_const_t<U>;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;

iterator_base() noexcept = default;

template <class V>
iterator_base(const iterator_base<V>& a_rhs) noexcept //
requires(std::convertible_to<typename iterator_base<V>::reference, reference>)
:
requires(std::convertible_to<typename iterator_base<V>::reference, reference>) :
_proxy(a_rhs._proxy),
_first(a_rhs._first),
_last(a_rhs._last)
Expand All @@ -107,6 +94,11 @@ namespace RE
return *std::launder(reinterpret_cast<pointer>(_first));
}

[[nodiscard]] pointer operator->() const noexcept
{
return std::pointer_traits<pointer>::pointer_to(operator*());
}

template <class V>
[[nodiscard]] bool operator==(const iterator_base<V>& a_rhs) const noexcept
{
Expand All @@ -119,16 +111,28 @@ namespace RE
}
}

using super::operator++;
template <class V>
[[nodiscard]] bool operator!=(const iterator_base<V>& a_rhs) const noexcept
{
return !operator==(a_rhs);
}

void operator++() noexcept
iterator_base& operator++() noexcept
{
assert(good());
_first += sizeof(value_type);
if (_first == _proxy->cend() && _first != _last) {
_proxy = _proxy->next;
_first = _proxy->begin();
}
return *this;
}

iterator_base operator++(int) noexcept
{
iterator_base tmp{ *this };
operator++();
return tmp;
}

protected:
Expand Down
3 changes: 1 addition & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"host": true
},
"spdlog",
"xbyak",
"boost-stl-interfaces"
"xbyak"
]
}

0 comments on commit 107987c

Please sign in to comment.