From adf1ecd97716e9757620691e28315a03238d1698 Mon Sep 17 00:00:00 2001 From: MacroModel <33865334+MacroModel@users.noreply.github.com> Date: Thu, 28 Nov 2024 23:41:16 +0800 Subject: [PATCH] update freestanding impl --- include/fast_io_freestanding_impl/generator.h | 26 ++++---- .../io_buffer/io_buffer.h | 10 +-- .../io_buffer/mode.h | 2 +- .../io_deco_filter/io_deco_filter.h | 10 +-- .../scanners/line_scanner.h | 20 +++--- .../transcoders/transcoder_file.h | 62 +++++++++---------- include/fast_io_freestanding_impl/width.h | 16 ++--- 7 files changed, 73 insertions(+), 73 deletions(-) diff --git a/include/fast_io_freestanding_impl/generator.h b/include/fast_io_freestanding_impl/generator.h index 1ad9d087b..e4bcadc49 100644 --- a/include/fast_io_freestanding_impl/generator.h +++ b/include/fast_io_freestanding_impl/generator.h @@ -22,25 +22,25 @@ class generator_promise #ifdef __cpp_exceptions ::std::exception_ptr ex_ptr; #endif - generator get_return_object() noexcept; + inline generator get_return_object() noexcept; - constexpr ::std::suspend_always initial_suspend() const noexcept + inline constexpr ::std::suspend_always initial_suspend() const noexcept { return {}; } - constexpr ::std::suspend_always final_suspend() const noexcept + inline constexpr ::std::suspend_always final_suspend() const noexcept { return {}; } // template // requires ::std::same_as<::std::remove_reference_t,::std::remove_reference_t> - constexpr ::std::suspend_always yield_value(T value) noexcept + inline constexpr ::std::suspend_always yield_value(T value) noexcept { ptr = value; // ptr = __builtin_addressof(value); return {}; } - constexpr void unhandled_exception() noexcept + inline constexpr void unhandled_exception() noexcept { #ifdef __cpp_exceptions ex_ptr = ::std::current_exception(); @@ -48,12 +48,12 @@ class generator_promise ::std::terminate(); #endif } - constexpr void return_void() noexcept + inline constexpr void return_void() noexcept {} template - ::std::suspend_never await_transform(U &&value) = delete; + inline ::std::suspend_never await_transform(U &&value) = delete; - void rethrow_if_exception() + inline void rethrow_if_exception() { #ifdef __cpp_exceptions if (ex_ptr) @@ -143,12 +143,12 @@ class [[nodiscard]] generator public: using promise_type = details::generator_promise; ::std::coroutine_handle handle; - constexpr generator(::std::coroutine_handle v) + inline constexpr generator(::std::coroutine_handle v) : handle(v) {} - constexpr generator(generator const &) noexcept = delete; - constexpr generator &operator=(generator const &) noexcept = delete; - constexpr ~generator() + inline constexpr generator(generator const &) noexcept = delete; + inline constexpr generator &operator=(generator const &) noexcept = delete; + inline constexpr ~generator() { handle.destroy(); } @@ -214,4 +214,4 @@ inline generator generator_promise::get_return_object() noexcept return {coroutine_handle::from_promise(*this)}; } } // namespace details -} // namespace fast_io \ No newline at end of file +} // namespace fast_io diff --git a/include/fast_io_freestanding_impl/io_buffer/io_buffer.h b/include/fast_io_freestanding_impl/io_buffer/io_buffer.h index d1c512c90..8b10d3971 100644 --- a/include/fast_io_freestanding_impl/io_buffer/io_buffer.h +++ b/include/fast_io_freestanding_impl/io_buffer/io_buffer.h @@ -67,9 +67,9 @@ class basic_io_buffer : handle(::std::forward(args)...) { } - basic_io_buffer &operator=(basic_io_buffer const &) = delete; - basic_io_buffer(basic_io_buffer const &) = delete; - constexpr basic_io_buffer(basic_io_buffer &&__restrict other) noexcept + inline basic_io_buffer &operator=(basic_io_buffer const &) = delete; + inline basic_io_buffer(basic_io_buffer const &) = delete; + inline constexpr basic_io_buffer(basic_io_buffer &&__restrict other) noexcept : input_buffer(::std::move(other.input_buffer)), output_buffer(::std::move(other.output_buffer)), handle(::std::move(other.handle)) { @@ -105,7 +105,7 @@ class basic_io_buffer handle = handle_type(); } } - constexpr basic_io_buffer &operator=(basic_io_buffer &&__restrict other) noexcept + inline constexpr basic_io_buffer &operator=(basic_io_buffer &&__restrict other) noexcept { ::fast_io::details::destroy_basic_io_buffer(*this); input_buffer = ::std::move(other.input_buffer); @@ -116,7 +116,7 @@ class basic_io_buffer return *this; } - constexpr ~basic_io_buffer() + inline constexpr ~basic_io_buffer() { ::fast_io::details::destroy_basic_io_buffer(*this); } diff --git a/include/fast_io_freestanding_impl/io_buffer/mode.h b/include/fast_io_freestanding_impl/io_buffer/mode.h index d767dc7a2..fc230a2e1 100644 --- a/include/fast_io_freestanding_impl/io_buffer/mode.h +++ b/include/fast_io_freestanding_impl/io_buffer/mode.h @@ -110,7 +110,7 @@ namespace details { template -constexpr ::std::size_t compute_default_buffer_size() noexcept +inline constexpr ::std::size_t compute_default_buffer_size() noexcept { if constexpr (::std::same_as) { diff --git a/include/fast_io_freestanding_impl/io_deco_filter/io_deco_filter.h b/include/fast_io_freestanding_impl/io_deco_filter/io_deco_filter.h index 597a4f9de..f6ce42d20 100644 --- a/include/fast_io_freestanding_impl/io_deco_filter/io_deco_filter.h +++ b/include/fast_io_freestanding_impl/io_deco_filter/io_deco_filter.h @@ -51,9 +51,9 @@ class basic_io_deco_filter : handle(::std::forward(args)...), decorators(::fast_io::freestanding::forward(d)) { } - basic_io_deco_filter &operator=(basic_io_deco_filter const &) = delete; - basic_io_deco_filter(basic_io_deco_filter const &) = delete; - constexpr basic_io_deco_filter(basic_io_deco_filter &&__restrict other) noexcept + inline basic_io_deco_filter &operator=(basic_io_deco_filter const &) = delete; + inline basic_io_deco_filter(basic_io_deco_filter const &) = delete; + inline constexpr basic_io_deco_filter(basic_io_deco_filter &&__restrict other) noexcept : input_buffer(::std::move(other.input_buffer)), handle(::std::move(other.handle)), decorators(::std::move(other.decorators)) { @@ -86,7 +86,7 @@ class basic_io_deco_filter handle = handle_type(); } } - constexpr basic_io_deco_filter &operator=(basic_io_deco_filter &&__restrict other) noexcept + inline constexpr basic_io_deco_filter &operator=(basic_io_deco_filter &&__restrict other) noexcept { ::fast_io::details::destroy_basic_io_filter(*this); input_buffer = ::std::move(other.input_buffer); @@ -96,7 +96,7 @@ class basic_io_deco_filter return *this; } - constexpr ~basic_io_deco_filter() + inline constexpr ~basic_io_deco_filter() { ::fast_io::details::destroy_basic_io_filter(*this); } diff --git a/include/fast_io_freestanding_impl/scanners/line_scanner.h b/include/fast_io_freestanding_impl/scanners/line_scanner.h index 8dc07f5de..10c2db843 100644 --- a/include/fast_io_freestanding_impl/scanners/line_scanner.h +++ b/include/fast_io_freestanding_impl/scanners/line_scanner.h @@ -11,17 +11,17 @@ struct basic_line_scanner_buffer char_type *begin_ptr{}; char_type *curr_ptr{}; char_type *end_ptr{}; - constexpr buffer_type() noexcept + inline constexpr buffer_type() noexcept : begin_ptr(nullptr), curr_ptr(nullptr), end_ptr(nullptr) {} - buffer_type(buffer_type const &) = delete; - buffer_type &operator=(buffer_type const &) = delete; - constexpr buffer_type(buffer_type &&__restrict other) noexcept + inline buffer_type(buffer_type const &) = delete; + inline buffer_type &operator=(buffer_type const &) = delete; + inline constexpr buffer_type(buffer_type &&__restrict other) noexcept : begin_ptr(other.begin_ptr), curr_ptr(other.curr_ptr), end_ptr(other.end_ptr) { other.end_ptr = other.curr_ptr = other.begin_ptr = nullptr; } - constexpr buffer_type &operator=(buffer_type &&__restrict other) noexcept + inline constexpr buffer_type &operator=(buffer_type &&__restrict other) noexcept { ::fast_io::details::deallocate_iobuf_space( this->begin_ptr, static_cast<::std::size_t>(this->end_ptr - this->begin_ptr)); @@ -30,7 +30,7 @@ struct basic_line_scanner_buffer this->end_ptr = other.end_ptr; other.end_ptr = other.curr_ptr = other.begin_ptr = nullptr; } - constexpr ~buffer_type() + inline constexpr ~buffer_type() { ::fast_io::details::deallocate_iobuf_space( this->begin_ptr, static_cast<::std::size_t>(this->end_ptr - this->begin_ptr)); @@ -40,11 +40,11 @@ struct basic_line_scanner_buffer char_type const *view_begin_ptr{}; char_type const *view_end_ptr{}; bool inbuffer{}; - constexpr char_type const *begin() const noexcept + inline constexpr char_type const *begin() const noexcept { return view_begin_ptr; } - constexpr char_type const *end() const noexcept + inline constexpr char_type const *end() const noexcept { return view_end_ptr; } @@ -55,11 +55,11 @@ struct basic_line_scanner_contiguous_view { char_type const *view_begin_ptr{}; char_type const *view_end_ptr{}; - constexpr char_type const *begin() const noexcept + inline constexpr char_type const *begin() const noexcept { return view_begin_ptr; } - constexpr char_type const *end() const noexcept + inline constexpr char_type const *end() const noexcept { return view_end_ptr; } diff --git a/include/fast_io_freestanding_impl/transcoders/transcoder_file.h b/include/fast_io_freestanding_impl/transcoders/transcoder_file.h index 4112de7cc..36ece950e 100644 --- a/include/fast_io_freestanding_impl/transcoders/transcoder_file.h +++ b/include/fast_io_freestanding_impl/transcoders/transcoder_file.h @@ -5,14 +5,14 @@ namespace fast_io struct transcoder_file_base { - virtual constexpr bool transcode_always_none() const = 0; - virtual constexpr ::std::size_t transcode_bytes_min_tosize() const = 0; - virtual constexpr ::std::size_t transcode_bytes_size(::std::byte const *, ::std::byte const *, ::std::size_t) const = 0; - virtual constexpr transcode_bytes_result transcode_bytes(::std::byte const *, ::std::byte const *, ::std::byte *, ::std::byte *) = 0; - virtual constexpr ::std::size_t transcode_bytes_do_final_tosize() const = 0; - virtual constexpr ::std::byte *transcode_bytes_do_final(::std::byte *, ::std::byte *) = 0; - virtual void destroy() noexcept = 0; - constexpr ~transcoder_file_base() = default; + inline virtual constexpr bool transcode_always_none() const = 0; + inline virtual constexpr ::std::size_t transcode_bytes_min_tosize() const = 0; + inline virtual constexpr ::std::size_t transcode_bytes_size(::std::byte const *, ::std::byte const *, ::std::size_t) const = 0; + inline virtual constexpr transcode_bytes_result transcode_bytes(::std::byte const *, ::std::byte const *, ::std::byte *, ::std::byte *) = 0; + inline virtual constexpr ::std::size_t transcode_bytes_do_final_tosize() const = 0; + inline virtual constexpr ::std::byte *transcode_bytes_do_final(::std::byte *, ::std::byte *) = 0; + inline virtual void destroy() noexcept = 0; + inline constexpr ~transcoder_file_base() = default; }; template @@ -20,11 +20,11 @@ template struct transcoder_file_derived final : transcoder_file_base { T object; - explicit constexpr basic_transcoder_file(::fast_io::io_cookie_type_t, Args &&args...) + inline explicit constexpr basic_transcoder_file(::fast_io::io_cookie_type_t, Args &&args...) : object(::std::forward(args)...) { } - constexpr bool transcode_always_none() const override + inline constexpr bool transcode_always_none() const override { if constexpr (requires() { object.transcode_always_none(); @@ -37,7 +37,7 @@ struct transcoder_file_derived final : transcoder_file_base return false; } } - constexpr ::std::size_t transcode_bytes_min_tosize() const override + inline constexpr ::std::size_t transcode_bytes_min_tosize() const override { concept has_transcode_bytes_min_tosize = requires() { { object.transcode_bytes_min_tosize() } -> ::std::same_as<::std::size_t>; @@ -51,7 +51,7 @@ struct transcoder_file_derived final : transcoder_file_base return object.transcode_min_tosize() * sizeof(typename T::to_value_type); } } - constexpr ::std::size_t transcode_bytes_size(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::size_t mxsz) const override + inline constexpr ::std::size_t transcode_bytes_size(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::size_t mxsz) const override { concept has_transcode_bytes_size = requires() { { object.transcode_bytes_size(fromfirst, fromlast, mxsz) } -> ::std::same_as<::std::size_t>; @@ -75,7 +75,7 @@ struct transcoder_file_derived final : transcoder_file_base sizeof(from_value_type); } } - constexpr transcode_bytes_result transcode_bytes(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::byte *tofirst, ::std::byte *tolast) override + inline constexpr transcode_bytes_result transcode_bytes(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::byte *tofirst, ::std::byte *tolast) override { concept has_transcode_bytes = requires() { { object.transcode_bytes(fromfirst, fromlast, tofirst, tolast) } -> ::std::same_as; @@ -105,7 +105,7 @@ struct transcoder_file_derived final : transcoder_file_base return {reinterpret_cast<::std::byte const *>(fromit), reinterpret_cast<::std::byte *>(toit)}; } } - constexpr ::std::size_t transcode_bytes_do_final_tosize() override + inline constexpr ::std::size_t transcode_bytes_do_final_tosize() override { if constexpr (requires() { { object.transcode_bytes_do_final_tosize() } -> ::std::same_as<::std::size_t>; @@ -124,7 +124,7 @@ struct transcoder_file_derived final : transcoder_file_base return 0; } } - constexpr ::std::byte *transcode_bytes_do_final(::std::byte *tofirst, ::std::byte *tolast) override + inline constexpr ::std::byte *transcode_bytes_do_final(::std::byte *tofirst, ::std::byte *tolast) override { if constexpr (requires() { { object.transcode_bytes_do_final(tofirst, tolast) } -> ::std::same_as<::std::byte *>; @@ -153,7 +153,7 @@ struct transcoder_file_derived final : transcoder_file_base return fromfirst; } } - constexpr void destroy() noexcept override + inline constexpr void destroy() noexcept override { ::std::destroy(this); ::fast_io::typed_allocator_adapter>::deallocate(this, 1); @@ -165,38 +165,38 @@ class transcoder_io_observer public: using native_handle_type = transcoder_file_base *; native_handle_type transhandle{}; - constexpr native_handle_type release() noexcept + inline constexpr native_handle_type release() noexcept { auto temptranshandle{transhandle}; this->transhandle = nullptr; return temptranshandle; } - constexpr native_handle_type native_handle() const noexcept + inline constexpr native_handle_type native_handle() const noexcept { return this->transhandle; } - constexpr bool transcode_always_none() const + inline constexpr bool transcode_always_none() const { return transhandle->transcode_always_none(); } - constexpr ::std::size_t transcode_bytes_minsize() const + inline constexpr ::std::size_t transcode_bytes_minsize() const { return transhandle->transcode_bytes_minsize(); } - constexpr ::std::size_t transcode_bytes_size(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::size_t mxsz) const + inline constexpr ::std::size_t transcode_bytes_size(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::size_t mxsz) const { return transhandle->transcode_bytes_size(fromfirst, fromlast, mxsz); } - constexpr transcode_bytes_result transcode_bytes(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::byte *tofirst, ::std::byte *tolast) + inline constexpr transcode_bytes_result transcode_bytes(::std::byte const *fromfirst, ::std::byte const *fromlast, ::std::byte *tofirst, ::std::byte *tolast) { return transhandle->transcode_bytes(fromfirst, fromlast, tofirst, tolast); } - constexpr ::std::size_t transcode_bytes_do_final_tosize() const + inline constexpr ::std::size_t transcode_bytes_do_final_tosize() const { return transhandle->transcode_bytes_do_final_tosize(); } - constexpr ::std::byte *transcode_bytes_do_final(::std::byte *tofirst, ::std::byte *tolast) + inline constexpr ::std::byte *transcode_bytes_do_final(::std::byte *tofirst, ::std::byte *tolast) { return transhandle->transcode_bytes_do_final(tofirst, tolast); } @@ -211,19 +211,19 @@ class basic_transcoder_file : public transcoder_io_observer using transcoder_io_observer::transhandle; template requires ::std::constructible_from - explicit constexpr basic_transcoder_file(::fast_io::io_cookie_type_t, Args &&args...) + inline explicit constexpr basic_transcoder_file(::fast_io::io_cookie_type_t, Args &&args...) : transcoder_io_observer{::std::construct_at(typed_allocator_adapter>::allocate(1), ::fast_io::io_cookie_type, ::std::forward(args)...)} { } - constexpr basic_transcoder_file(basic_transcoder_file const &) = delete; - constexpr basic_transcoder_file &operator=(basic_transcoder_file const &) = delete; + inline constexpr basic_transcoder_file(basic_transcoder_file const &) = delete; + inline constexpr basic_transcoder_file &operator=(basic_transcoder_file const &) = delete; - constexpr basic_transcoder_file(basic_transcoder_file &&other) noexcept + inline constexpr basic_transcoder_file(basic_transcoder_file &&other) noexcept : transhandle{other.handle} { other.transhandle = nullptr; } - constexpr basic_transcoder_file &operator=(basic_transcoder_file &&other) noexcept + inline constexpr basic_transcoder_file &operator=(basic_transcoder_file &&other) noexcept { if (__builtin_addressof(other) == this) { @@ -234,12 +234,12 @@ class basic_transcoder_file : public transcoder_io_observer other.transhandle = nullptr; return *this; } - constexpr void close() noexcept + inline constexpr void close() noexcept { this->transhandle->destroy(); this->transhandle = nullptr; } - constexpr ~basic_transcoder_file() + inline constexpr ~basic_transcoder_file() { this->transhandle->destroy(); } diff --git a/include/fast_io_freestanding_impl/width.h b/include/fast_io_freestanding_impl/width.h index e23d7fe23..de9d8d066 100644 --- a/include/fast_io_freestanding_impl/width.h +++ b/include/fast_io_freestanding_impl/width.h @@ -486,7 +486,7 @@ template <::std::integral char_type, ::fast_io::manipulators::scalar_placement p scatter_printable>) && (static_cast<::std::size_t>(static_cast<::std::size_t>(placement) - static_cast<::std::size_t>(1u)) < static_cast<::std::size_t>(4u))) -constexpr ::std::size_t print_reserve_size(io_reserve_type_t>, +inline constexpr ::std::size_t print_reserve_size(io_reserve_type_t>, ::fast_io::manipulators::width_t t) noexcept { if constexpr (::std::is_reference_v) @@ -505,7 +505,7 @@ template <::std::integral char_type, ::fast_io::manipulators::scalar_placement p scatter_printable>) && (static_cast<::std::size_t>(static_cast<::std::size_t>(placement) - static_cast<::std::size_t>(1u)) < static_cast<::std::size_t>(4u))) -constexpr char_type *print_reserve_define(io_reserve_type_t>, +inline constexpr char_type *print_reserve_define(io_reserve_type_t>, char_type *iter, ::fast_io::manipulators::width_t t) noexcept { if constexpr (::std::is_reference_v) @@ -524,7 +524,7 @@ template <::std::integral char_type, ::fast_io::manipulators::scalar_placement p scatter_printable>) && (static_cast<::std::size_t>(static_cast<::std::size_t>(placement) - static_cast<::std::size_t>(1u)) < static_cast<::std::size_t>(4u))) -constexpr ::std::size_t +inline constexpr ::std::size_t print_reserve_size(io_reserve_type_t>, ::fast_io::manipulators::width_ch_t t) noexcept { @@ -544,7 +544,7 @@ template <::std::integral char_type, ::fast_io::manipulators::scalar_placement p scatter_printable>) && (static_cast<::std::size_t>(static_cast<::std::size_t>(placement) - static_cast<::std::size_t>(1u)) < static_cast<::std::size_t>(4u))) -constexpr char_type * +inline constexpr char_type * print_reserve_define(io_reserve_type_t>, char_type *iter, ::fast_io::manipulators::width_ch_t t) noexcept { @@ -563,7 +563,7 @@ template <::std::integral char_type, typename T> requires(reserve_printable> || dynamic_reserve_printable> || scatter_printable>) -constexpr ::std::size_t print_reserve_size(io_reserve_type_t>, +inline constexpr ::std::size_t print_reserve_size(io_reserve_type_t>, ::fast_io::manipulators::width_runtime_t t) noexcept { if constexpr (::std::is_reference_v) @@ -580,7 +580,7 @@ template <::std::integral char_type, typename T> requires(reserve_printable> || dynamic_reserve_printable> || scatter_printable>) -constexpr char_type *print_reserve_define(io_reserve_type_t>, +inline constexpr char_type *print_reserve_define(io_reserve_type_t>, char_type *iter, ::fast_io::manipulators::width_runtime_t t) noexcept { if constexpr (::std::is_reference_v) @@ -598,7 +598,7 @@ template <::std::integral char_type, typename T> requires(reserve_printable> || dynamic_reserve_printable> || scatter_printable>) -constexpr ::std::size_t +inline constexpr ::std::size_t print_reserve_size(io_reserve_type_t>, ::fast_io::manipulators::width_runtime_ch_t t) noexcept { @@ -616,7 +616,7 @@ template <::std::integral char_type, typename T> requires(reserve_printable> || dynamic_reserve_printable> || scatter_printable>) -constexpr char_type * +inline constexpr char_type * print_reserve_define(io_reserve_type_t>, char_type *iter, ::fast_io::manipulators::width_runtime_ch_t t) noexcept {