Skip to content

Commit c986bc1

Browse files
committed
Refactor get function signatures in tuple.h for improved type deduction
- Updated `get` function signatures to return `auto&&` instead of `decltype(auto)` for better type handling. - Enhanced consistency across all overloads of `get` by applying uniform return types. - Minor adjustments made to improve readability and maintainability of the code.
1 parent e9f5daf commit c986bc1

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

include/fast_io_dsal/impl/tuple.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,23 @@ tuple(Args &&...) -> tuple<Args...>;
9696
template <::std::size_t I, typename... Args>
9797
FAST_IO_GNU_ALWAYS_INLINE
9898
[[nodiscard]]
99-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &self) noexcept
99+
constexpr auto&& get(::fast_io::containers::tuple<Args...> &self) noexcept
100100
{
101101
return static_cast<::fast_io::containers::details::tuple_element_impl_<I, ::fast_io::containers::details::pack_indexing_t_<I, Args...>> &>(self).val_;
102102
}
103103

104104
template <::std::size_t I, typename... Args>
105105
FAST_IO_GNU_ALWAYS_INLINE
106106
[[nodiscard]]
107-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> const &self) noexcept
107+
constexpr auto&& get(::fast_io::containers::tuple<Args...> const &self) noexcept
108108
{
109109
return static_cast<::fast_io::containers::details::tuple_element_impl_<I, ::fast_io::containers::details::pack_indexing_t_<I, Args...>> const &>(self).val_;
110110
}
111111

112112
template <::std::size_t I, typename... Args>
113113
FAST_IO_GNU_ALWAYS_INLINE
114114
[[nodiscard]]
115-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &&self) noexcept
115+
constexpr auto&& get(::fast_io::containers::tuple<Args...> &&self) noexcept
116116
{
117117
return ::std::move(
118118
static_cast<::fast_io::containers::details::tuple_element_impl_<I, ::fast_io::containers::details::pack_indexing_t_<I, Args...>> &&>(self).val_);
@@ -121,7 +121,7 @@ FAST_IO_GNU_ALWAYS_INLINE
121121
template <::std::size_t I, typename... Args>
122122
FAST_IO_GNU_ALWAYS_INLINE
123123
[[nodiscard]]
124-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> const &&self) noexcept
124+
constexpr auto&& get(::fast_io::containers::tuple<Args...> const &&self) noexcept
125125
{
126126
return ::std::move(
127127
static_cast<::fast_io::containers::details::tuple_element_impl_<I, ::fast_io::containers::details::pack_indexing_t_<I, Args...>> const &&>(self).val_);
@@ -149,7 +149,7 @@ template <typename T, typename... Args>
149149
requires((::std::same_as<T, Args> + ...) == 1)
150150
FAST_IO_GNU_ALWAYS_INLINE
151151
[[nodiscard]]
152-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> const &self) noexcept
152+
constexpr auto&& get(::fast_io::containers::tuple<Args...> const &self) noexcept
153153
{
154154
return static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &>(self).val_;
155155
}
@@ -158,7 +158,7 @@ template <typename T, typename... Args>
158158
requires((::std::same_as<T, Args> + ...) == 1)
159159
FAST_IO_GNU_ALWAYS_INLINE
160160
[[nodiscard]]
161-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> const &&self) noexcept
161+
constexpr auto&& get(::fast_io::containers::tuple<Args...> const &&self) noexcept
162162
{
163163
return ::std::move(
164164
static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &&>(self).val_);
@@ -168,7 +168,7 @@ template <typename T, typename... Args>
168168
requires((::std::same_as<T, Args> + ...) == 1)
169169
FAST_IO_GNU_ALWAYS_INLINE
170170
[[nodiscard]]
171-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &self) noexcept
171+
constexpr auto&& get(::fast_io::containers::tuple<Args...> &self) noexcept
172172
{
173173
return static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &>(self).val_;
174174
}
@@ -177,7 +177,7 @@ template <typename T, typename... Args>
177177
requires((::std::same_as<T, Args> + ...) == 1)
178178
FAST_IO_GNU_ALWAYS_INLINE
179179
[[nodiscard]]
180-
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &&self) noexcept
180+
constexpr auto&& get(::fast_io::containers::tuple<Args...> &&self) noexcept
181181
{
182182
return ::std::move(
183183
static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &&>(self).val_);

include/fast_io_hosted/platforms/posix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ inline void posix_truncate_impl(int fd, ::fast_io::uintfpos_t size)
14481448
auto err(noexcept_call(_chsize_s, fd, static_cast<::std::int_least64_t>(size)));
14491449
if (err)
14501450
{
1451-
throw_posix_error(err);
1451+
throw_posix_error();
14521452
}
14531453
#else
14541454
if (size > ::std::numeric_limits<long>::max())
@@ -1458,7 +1458,7 @@ inline void posix_truncate_impl(int fd, ::fast_io::uintfpos_t size)
14581458
auto err(noexcept_call(_chsize, fd, static_cast<long>(size)));
14591459
if (err)
14601460
{
1461-
throw_posix_error(err);
1461+
throw_posix_error();
14621462
}
14631463
#endif
14641464

include/fast_io_hosted/platforms/win32.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ inline void *create_win32_temp_file_impl()
115115
{
116116
throw_win32_error();
117117
}
118+
if (temp_path_size > 122 /*ERROR_INSUFFICIENT_BUFFER*/) [[unlikely]]
119+
{
120+
throw_win32_error(ERROR_INVALID_PARAMETER);
121+
}
118122
auto arrp{arr + temp_path_size};
119123
constexpr bool winver_support_rtl_gen_random{
120124
#if !defined(_WIN32_WINDOWS) && (!defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0501)

0 commit comments

Comments
 (0)