From 107987c73826c00c2f685f29a5b3f879aa55f5d4 Mon Sep 17 00:00:00 2001 From: Angad <66992519+ThirdEyeSqueegee@users.noreply.github.com> Date: Tue, 23 Jul 2024 22:48:08 -0700 Subject: [PATCH] fix: remove Boost (port `BSTObjectArena.h` from CommonLibF4) (#257) --- CMakeLists.txt | 12 +++------ include/RE/B/BSTObjectArena.h | 48 +++++++++++++++++++---------------- vcpkg.json | 3 +-- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4b71e5a..8f98c14e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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) @@ -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( @@ -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 "$<$:SFSE_SUPPORT_XBYAK=1>" @@ -115,7 +110,6 @@ function(configure_target TARGET_NAME) target_link_libraries( ${TARGET_NAME} PUBLIC - Boost::headers spdlog::spdlog Version.lib Dbghelp.lib diff --git a/include/RE/B/BSTObjectArena.h b/include/RE/B/BSTObjectArena.h index 1c407fef..169bbe82 100644 --- a/include/RE/B/BSTObjectArena.h +++ b/include/RE/B/BSTObjectArena.h @@ -1,7 +1,6 @@ #pragma once #include "RE/M/MemoryManager.h" -#include namespace RE { @@ -58,32 +57,20 @@ namespace RE private: template - class iterator_base : - public boost::stl_interfaces::iterator_interface< - iterator_base, - std::forward_iterator_tag, - U> + class iterator_base { - private: - using super = - boost::stl_interfaces::iterator_interface< - iterator_base, - 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; + using pointer = value_type*; + using reference = value_type&; + using iterator_category = std::forward_iterator_tag; iterator_base() noexcept = default; template iterator_base(const iterator_base& a_rhs) noexcept // - requires(std::convertible_to::reference, reference>) - : + requires(std::convertible_to::reference, reference>) : _proxy(a_rhs._proxy), _first(a_rhs._first), _last(a_rhs._last) @@ -107,6 +94,11 @@ namespace RE return *std::launder(reinterpret_cast(_first)); } + [[nodiscard]] pointer operator->() const noexcept + { + return std::pointer_traits::pointer_to(operator*()); + } + template [[nodiscard]] bool operator==(const iterator_base& a_rhs) const noexcept { @@ -119,9 +111,13 @@ namespace RE } } - using super::operator++; + template + [[nodiscard]] bool operator!=(const iterator_base& a_rhs) const noexcept + { + return !operator==(a_rhs); + } - void operator++() noexcept + iterator_base& operator++() noexcept { assert(good()); _first += sizeof(value_type); @@ -129,6 +125,14 @@ namespace RE _proxy = _proxy->next; _first = _proxy->begin(); } + return *this; + } + + iterator_base operator++(int) noexcept + { + iterator_base tmp{ *this }; + operator++(); + return tmp; } protected: diff --git a/vcpkg.json b/vcpkg.json index 1644b743..d95d2ca2 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -17,7 +17,6 @@ "host": true }, "spdlog", - "xbyak", - "boost-stl-interfaces" + "xbyak" ] }