From 7c2d9f15925555d1464eaa85761f970ec69d87f9 Mon Sep 17 00:00:00 2001 From: "M. Bahoosh" <12122474+the-moisrex@users.noreply.github.com> Date: Fri, 27 Dec 2024 04:45:51 -1000 Subject: [PATCH] Removing const-pins; #576 --- webpp/unicode/utf_reducer.hpp | 98 ----------------------------------- 1 file changed, 98 deletions(-) diff --git a/webpp/unicode/utf_reducer.hpp b/webpp/unicode/utf_reducer.hpp index ed0c977b..9b080913 100644 --- a/webpp/unicode/utf_reducer.hpp +++ b/webpp/unicode/utf_reducer.hpp @@ -376,76 +376,6 @@ namespace webpp::unicode { template struct utf_reducer; - template - struct const_pin_type { - using reducer_type = utf_reducer; - using iterator = typename reducer_type::iterator; - using size_type = typename reducer_type::size_type; - using value_type = typename reducer_type::value_type; - using unit_type = typename reducer_type::unit_type; - using difference_type = typename reducer_type::difference_type; - - static constexpr bool is_nothrow = reducer_type::is_nothrow; - - private: - template - friend struct const_pin_type; - - iterator ptr; - - /// guarantee the correctness of the state that we're in - constexpr void test_state_correctness() noexcept { - // early blow up in case we did not find the correct ptr position: - assert(is_code_unit_start(*iter())); - } - - public: - constexpr explicit const_pin_type(iterator inp_iter) noexcept : ptr{inp_iter} {} - - constexpr const_pin_type(const_pin_type&& other) noexcept = default; - constexpr const_pin_type& operator=(const_pin_type&& other) noexcept = default; - constexpr ~const_pin_type() noexcept = default; - constexpr const_pin_type(const_pin_type const& other) noexcept = default; - constexpr const_pin_type& operator=(const_pin_type const& other) noexcept = default; - - [[nodiscard]] constexpr iterator const& iter() const noexcept { - return ptr; - } - - [[nodiscard]] constexpr iterator& iter() noexcept { - return ptr; - } - - constexpr const_pin_type& operator++() noexcept(is_nothrow) { - if constexpr (UTF32) { - ++iter(); - } else { - unchecked::next_char(iter()); - } - // test_state_correctness(); - return *this; - } - - [[nodiscard]] constexpr value_type operator*() noexcept(is_nothrow) { - assert(is_code_unit_start(*iter())); - if constexpr (UTF32) { - return *iter(); - } else { - return checked::next_code_point_copy(iter()); - } - } - - template - [[nodiscard]] constexpr bool operator==(NIterT other) noexcept(is_nothrow) { - return iter() == other; - } - - template - [[nodiscard]] constexpr bool operator!=(NIterT other) noexcept(is_nothrow) { - return iter() != other; - } - }; - /** * Pin is a forward-iterator-like type that is designed to be used inside utf_reducer. * @@ -490,7 +420,6 @@ namespace webpp::unicode { template using if_utf32 = stl::conditional_t, istl::nothing_type, T>; - using const_pin_t = const_pin_type; [[no_unique_address]] if_not_utf32 reducer; [[no_unique_address]] if_utf32 ptr; @@ -648,11 +577,6 @@ namespace webpp::unicode { return iter() <=> other.iter(); } - constexpr pin_type& operator=(const_pin_t const& other) noexcept(is_nothrow) { - operator=(other.iter()); - return *this; - } - constexpr pin_type& operator=(iterator other) noexcept(is_nothrow) { assert(other >= iter()); if constexpr (UTF32) { @@ -905,8 +829,6 @@ namespace webpp::unicode { template using pin_type_of = pin_type; - using const_pin_t = const_pin_type; - public: // the reason why we take length instead of end position is because the end might be a const, but // we don't want the end to be a const internally. @@ -953,10 +875,6 @@ namespace webpp::unicode { return pin_type_of{this}; } - [[nodiscard]] constexpr const_pin_t const_pin() noexcept { - return const_pin_t{beg}; - } - [[nodiscard]] constexpr auto& all_pins() noexcept { return iters; } @@ -1007,17 +925,6 @@ namespace webpp::unicode { })(stl::make_index_sequence{}); } - /// Get a new set of const pins. - /// "Const Pins" are pins that cannot modify anything and are less restricted in moving around. - /// Usage: - /// auto [pin1, pin2, pin3] = reducer.template new_const_pins<3>(); - template - [[nodiscard]] constexpr auto new_const_pins() noexcept { - return ([&](stl::index_sequence) constexpr noexcept { - return stl::make_tuple((static_cast(I), const_pin())...); - })(stl::make_index_sequence{}); - } - [[nodiscard]] constexpr iterator begin() const noexcept { return beg; } @@ -1057,11 +964,6 @@ namespace webpp::unicode { newend = inp_end.iter(); } - constexpr void set_end(const_pin_t const& inp_end) noexcept { - newend = inp_end.iter(); - // *newend = static_cast('\0'); - } - [[nodiscard]] constexpr size_type size() const noexcept { return static_cast(newend - beg); }