From acecdae4aa46e2f2d6feb9a8082be8cf9eca98e3 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Mon, 2 Dec 2024 20:37:44 -0500 Subject: [PATCH] add always inline first before replacing with fast_io dsal containers --- .../fast_io_core_impl/freestanding/array.h | 72 ++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/include/fast_io_core_impl/freestanding/array.h b/include/fast_io_core_impl/freestanding/array.h index 44d5df65..7610915e 100644 --- a/include/fast_io_core_impl/freestanding/array.h +++ b/include/fast_io_core_impl/freestanding/array.h @@ -15,10 +15,20 @@ struct array using size_type = ::std::size_t; using difference_type = ::std::ptrdiff_t; T element[N]; +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T *data() noexcept { return element; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T const *data() const noexcept { return element; @@ -55,56 +65,114 @@ struct array { return element + N; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T const &front() const noexcept { return *element; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T &front() noexcept { return *element; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T const &back() const noexcept { constexpr size_type nm1{N - 1}; return element[nm1]; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T &back() noexcept { constexpr size_type nm1{N - 1}; return element[nm1]; } - +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T const &front_unchecked() const noexcept { return *element; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T &front_unchecked() noexcept { return *element; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T const &back_unchecked() const noexcept { constexpr size_type nm1{N - 1}; return element[nm1]; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T &back_unchecked() noexcept { constexpr size_type nm1{N - 1}; return element[nm1]; } - +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T const &operator[](::std::size_t i) const noexcept { return element[i]; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T &operator[](::std::size_t i) noexcept { return element[i]; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T const &index_unchecked(::std::size_t i) const noexcept { return element[i]; } +#if __has_cpp_attribute(__gnu__::__always_inline__) + [[__gnu__::__always_inline__]] +#elif __has_cpp_attribute(msvc::forceinline) + [[msvc::forceinline]] +#endif inline constexpr T &index_unchecked(::std::size_t i) noexcept { return element[i];