diff --git a/CMakePresets.json b/CMakePresets.json index 42b6c591..8add715c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -30,14 +30,6 @@ }, { "cacheVariables": { - "Boost_USE_STATIC_LIBS": { - "type": "BOOL", - "value": "ON" - }, - "Boost_USE_STATIC_RUNTIME": { - "type": "BOOL", - "value": "OFF" - }, "CMAKE_EXE_LINKER_FLAGS_RELEASE": { "type": "STRING", "value": "/DEBUG:FASTLINK" diff --git a/CommonLibF4/CMakeLists.txt b/CommonLibF4/CMakeLists.txt index 86a1a7b2..16709517 100644 --- a/CommonLibF4/CMakeLists.txt +++ b/CommonLibF4/CMakeLists.txt @@ -13,7 +13,6 @@ if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") message(FATAL_ERROR "in-source builds are not allowed") endif() -find_package(Boost MODULE REQUIRED) find_package(mmio REQUIRED CONFIG) find_package(spdlog REQUIRED CONFIG) @@ -37,7 +36,6 @@ add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}") target_compile_definitions( "${PROJECT_NAME}" PUBLIC - BOOST_STL_INTERFACES_DISABLE_CONCEPTS WINVER=0x0601 # windows 7, minimum supported version by fallout 4 _WIN32_WINNT=0x0601 "$<$:F4SE_SUPPORT_XBYAK=1>" @@ -96,7 +94,6 @@ target_link_libraries( "${PROJECT_NAME}" PUBLIC bcrypt.lib - Boost::headers mmio::mmio spdlog::spdlog Version.lib diff --git a/CommonLibF4/README.md b/CommonLibF4/README.md index 904860ec..c996f684 100644 --- a/CommonLibF4/README.md +++ b/CommonLibF4/README.md @@ -1,5 +1,3 @@ ## Build Dependencies -* [Boost](https://www.boost.org/) - * Stl_interfaces * [mmio](https://github.com/Ryan-rsm-McKenzie/mmio) * [spdlog](https://github.com/gabime/spdlog) diff --git a/CommonLibF4/cmake/config.cmake.in b/CommonLibF4/cmake/config.cmake.in index 5924af8b..d2a4c6bd 100644 --- a/CommonLibF4/cmake/config.cmake.in +++ b/CommonLibF4/cmake/config.cmake.in @@ -1,6 +1,5 @@ include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") include(CMakeFindDependencyMacro) -find_dependency(Boost MODULE) find_dependency(mmio CONFIG) find_dependency(spdlog CONFIG) diff --git a/CommonLibF4/include/F4SE/Impl/PCH.h b/CommonLibF4/include/F4SE/Impl/PCH.h index 2db2dcbe..65a0dfd6 100644 --- a/CommonLibF4/include/F4SE/Impl/PCH.h +++ b/CommonLibF4/include/F4SE/Impl/PCH.h @@ -40,7 +40,6 @@ static_assert( "wrap std::time_t instead"); #pragma warning(push, 0) -#include #include #include #pragma warning(pop) diff --git a/CommonLibF4/include/RE/Bethesda/BSTArray.h b/CommonLibF4/include/RE/Bethesda/BSTArray.h index 36afe9a0..693bba6c 100644 --- a/CommonLibF4/include/RE/Bethesda/BSTArray.h +++ b/CommonLibF4/include/RE/Bethesda/BSTArray.h @@ -223,17 +223,8 @@ namespace RE template < class T, class Allocator = BSTArrayHeapAllocator> - class BSTArray : - public boost::stl_interfaces::sequence_container_interface< - BSTArray, - boost::stl_interfaces::element_layout::contiguous> + class BSTArray { - private: - using super = - boost::stl_interfaces::sequence_container_interface< - BSTArray, - boost::stl_interfaces::element_layout::contiguous>; - public: using value_type = T; using allocator_type = Allocator; @@ -248,29 +239,6 @@ namespace RE using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - using super::operator=; - using super::operator[]; - - using super::assign; - using super::at; - using super::back; - using super::begin; - using super::cbegin; - using super::cend; - using super::clear; - using super::crbegin; - using super::crend; - using super::data; - using super::empty; - using super::end; - using super::erase; - using super::front; - using super::insert; - using super::push_back; - using super::rbegin; - using super::rend; - using super::size; - // 1) BSTArray() noexcept = default; @@ -358,10 +326,54 @@ namespace RE F4_HEAP_REDEFINE_NEW(BSTArray); - [[nodiscard]] iterator begin() noexcept { return static_cast(_allocator.data()); } - [[nodiscard]] iterator end() noexcept { return begin() + _size; } + constexpr reference at(size_type a_pos) + { + if (size() <= a_pos) + throw std::out_of_range("bounds check failed in BSTArray::at()"); + + return begin()[a_pos]; + } + + constexpr reference at(size_type a_pos) const + { + if (size() <= a_pos) + throw std::out_of_range("bounds check failed in BSTArray::at()"); + + return begin()[a_pos]; + } + + [[nodiscard]] constexpr reference operator[](size_type a_pos) noexcept { return begin()[a_pos]; } + [[nodiscard]] constexpr const_reference operator[](size_type a_pos) const noexcept { return begin()[a_pos]; } + + [[nodiscard]] constexpr reference front() noexcept { return operator[](0); } + [[nodiscard]] constexpr const_reference front() const noexcept { return operator[](0); } + + [[nodiscard]] constexpr reference back() noexcept { return operator[](size() - 1); } + [[nodiscard]] constexpr const_reference back() const noexcept { return operator[](size() - 1); } - [[nodiscard]] size_type max_size() const noexcept { return std::numeric_limits::max(); } + [[nodiscard]] constexpr pointer data() noexcept { return static_cast(_allocator.data()); } + [[nodiscard]] constexpr const_pointer data() const noexcept { return static_cast(_allocator.data()); } + + [[nodiscard]] constexpr iterator begin() noexcept { return data(); } + [[nodiscard]] constexpr const_iterator begin() const noexcept { return data(); } + [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); } + + [[nodiscard]] constexpr iterator end() noexcept { return begin() + size(); } + [[nodiscard]] constexpr const_iterator end() const noexcept { return begin() + size(); } + [[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); } + + [[nodiscard]] constexpr reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } + [[nodiscard]] constexpr const_reverse_iterator rbegin() const noexcept { return rbegin(); } + [[nodiscard]] constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); } + + [[nodiscard]] constexpr reverse_iterator rend() noexcept { return reverse_iterator(begin()); } + [[nodiscard]] constexpr const_reverse_iterator rend() const noexcept { return rend(); } + [[nodiscard]] constexpr const_reverse_iterator crend() const noexcept { return rend(); } + + [[nodiscard]] constexpr size_type size() const noexcept { return _size; } + [[nodiscard]] constexpr size_type max_size() const noexcept { return std::numeric_limits::max(); } + + [[nodiscard]] constexpr bool empty() const noexcept { size() == 0; } void reserve(size_type a_capacity) { @@ -370,10 +382,29 @@ namespace RE } } - [[nodiscard]] size_type capacity() const noexcept { return _allocator.capacity(); } + [[nodiscard]] constexpr size_type capacity() const noexcept { return _allocator.capacity(); } void shrink_to_fit() { reserve_exact(size()); } + template + void assign(ForwardIt a_first, ForwardIt a_last) + { + auto out = begin(); + auto const out_last = end(); + for (; out != out_last && a_first != a_last; ++a_first, ++out) { + *out = *a_first; + } + if (out != out_last) + erase(out, out_last); + if (a_first != a_last) + insert(end(), a_first, a_last); + } + + void assign(std::initializer_list a_init) + { + assign(a_init.begin(), a_init.end()); + } + template iterator insert(const_iterator a_pos, ForwardIt a_first, ForwardIt a_last) // requires(std::derived_from::iterator_category, std::forward_iterator_tag>) @@ -391,6 +422,21 @@ namespace RE return iter; } + iterator insert(const_iterator a_pos, value_type const& a_value) + { + return emplace(a_pos, a_value); + } + + iterator insert(const_iterator a_pos, value_type&& a_value) + { + return emplace(a_pos, std::move(a_value)); + } + + iterator insert(const_iterator a_pos, std::initializer_list a_init) + { + return insert(a_pos, a_init.begin(), a_init.end()); + } + template iterator emplace(const_iterator a_pos, Args&&... a_args) // requires(std::constructible_from) @@ -424,13 +470,33 @@ namespace RE return end(); } + iterator erase(const_iterator a_pos) + { + return erase(a_pos, std::next(a_pos)); + } + + void clear() + { + erase(begin(), end()); + } + template - reference emplace_back(Args&&... a_args) // + reference emplace_back(Args&&... a_args) requires(std::constructible_from) { return *emplace(end(), std::forward(a_args)...); } + void push_back(value_type const& a_value) + { + emplace_back(a_value); + } + + void push_back(value_type&& a_value) + { + emplace_back(std::move(a_value)); + } + void pop_back() { erase(std::prev(end())); } void resize(size_type a_count) { resize_impl(a_count, nullptr); } @@ -443,6 +509,12 @@ namespace RE a_rhs = std::move(tmp); } + auto operator=(std::initializer_list a_init) + { + assign(a_init.begin(), a_init.end()); + return *this; + } + private: [[nodiscard]] iterator decay_iterator(const_iterator a_iter) noexcept { diff --git a/CommonLibF4/vcpkg.json b/CommonLibF4/vcpkg.json index 6c142fdc..e4c72371 100644 --- a/CommonLibF4/vcpkg.json +++ b/CommonLibF4/vcpkg.json @@ -6,7 +6,6 @@ "license": "MIT", "supports": "windows & x64", "dependencies": [ - "boost-stl-interfaces", "rsm-mmio", "spdlog" ] diff --git a/vcpkg.json b/vcpkg.json index 862341b4..f24f8492 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,7 +3,6 @@ "version-string": "1", "dependencies": [ "args", - "boost-stl-interfaces", "rsm-mmio", "spdlog", "xbyak"