Skip to content

Commit 0e8e82d

Browse files
committed
Refactor tuple element access in fast_io_dsal
- Updated `get` function signatures in `tuple.h` to return `decltype(auto)` for improved type deduction. - Enhanced consistency by ensuring `[[nodiscard]]` attribute is applied uniformly across all overloads of `get`. - Added new overloads for `get` to support retrieval by type, improving usability and flexibility. - Minor formatting adjustments for better readability in the `forward_as_tuple` function.
1 parent 2748df5 commit 0e8e82d

2 files changed

Lines changed: 37 additions & 16 deletions

File tree

include/fast_io_dsal/impl/tuple.h

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,33 @@ tuple(Args &&...) -> tuple<Args...>;
9494

9595
template <::std::size_t I, typename... Args>
9696
FAST_IO_GNU_ALWAYS_INLINE
97-
[[nodiscard]]
98-
constexpr auto&& get(::fast_io::containers::tuple<Args...> &self) noexcept
97+
[[nodiscard]]
98+
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &self) noexcept
9999
{
100100
return static_cast<::fast_io::containers::details::tuple_element_impl_<I, ::fast_io::containers::details::pack_indexing_t_<I, Args...>> &>(self).val_;
101101
}
102102

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

111111
template <::std::size_t I, typename... Args>
112112
FAST_IO_GNU_ALWAYS_INLINE
113-
[[nodiscard]]
114-
constexpr auto&& get(::fast_io::containers::tuple<Args...> &&self) noexcept
113+
[[nodiscard]]
114+
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &&self) noexcept
115115
{
116116
return ::std::move(
117117
static_cast<::fast_io::containers::details::tuple_element_impl_<I, ::fast_io::containers::details::pack_indexing_t_<I, Args...>> &&>(self).val_);
118118
}
119119

120120
template <::std::size_t I, typename... Args>
121121
FAST_IO_GNU_ALWAYS_INLINE
122-
[[nodiscard]]
123-
constexpr auto&& get(::fast_io::containers::tuple<Args...> const &&self) noexcept
122+
[[nodiscard]]
123+
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> const &&self) noexcept
124124
{
125125
return ::std::move(
126126
static_cast<::fast_io::containers::details::tuple_element_impl_<I, ::fast_io::containers::details::pack_indexing_t_<I, Args...>> const &&>(self).val_);
@@ -147,17 +147,36 @@ constexpr auto get_tuple_element_by_type_() noexcept
147147
template <typename T, typename... Args>
148148
requires((::std::same_as<T, Args> + ...) == 1)
149149
FAST_IO_GNU_ALWAYS_INLINE
150-
[[nodiscard]]
151-
constexpr auto&& get(::fast_io::containers::tuple<Args...> const &self) noexcept
150+
[[nodiscard]]
151+
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> const &self) noexcept
152152
{
153153
return static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &>(self).val_;
154154
}
155155

156156
template <typename T, typename... Args>
157157
requires((::std::same_as<T, Args> + ...) == 1)
158158
FAST_IO_GNU_ALWAYS_INLINE
159-
[[nodiscard]]
160-
constexpr auto&& get(::fast_io::containers::tuple<Args...> const &&self) noexcept
159+
[[nodiscard]]
160+
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> const &&self) noexcept
161+
{
162+
return ::std::move(
163+
static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &&>(self).val_);
164+
}
165+
166+
template <typename T, typename... Args>
167+
requires((::std::same_as<T, Args> + ...) == 1)
168+
FAST_IO_GNU_ALWAYS_INLINE
169+
[[nodiscard]]
170+
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &self) noexcept
171+
{
172+
return static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &>(self).val_;
173+
}
174+
175+
template <typename T, typename... Args>
176+
requires((::std::same_as<T, Args> + ...) == 1)
177+
FAST_IO_GNU_ALWAYS_INLINE
178+
[[nodiscard]]
179+
constexpr decltype(auto) get(::fast_io::containers::tuple<Args...> &&self) noexcept
161180
{
162181
return ::std::move(
163182
static_cast<decltype(::fast_io::containers::details::get_tuple_element_by_type_<T, 0, Args...>())::type const &&>(self).val_);
@@ -177,15 +196,15 @@ constexpr bool is_tuple_<tuple<Args...>> = true;
177196
template <typename T>
178197
concept is_tuple = ::fast_io::containers::details::is_tuple_<::std::remove_cvref_t<T>>;
179198

180-
template<typename... Args>
199+
template <typename... Args>
181200
[[nodiscard]]
182-
constexpr auto forward_as_tuple(Args&&... args)
201+
constexpr auto forward_as_tuple(Args &&...args)
183202
{
184203
#if defined(__clang__)
185204
#pragma clang diagnostic push
186205
#pragma clang diagnostic ignored "-Wmissing-braces"
187206
#endif
188-
return ::fast_io::containers::tuple<Args&&...>{::std::forward<Args>(args)...};
207+
return ::fast_io::containers::tuple<Args &&...>{::std::forward<Args>(args)...};
189208
#if defined(__clang__)
190209
#pragma clang diagnostic pop
191210
#endif

include/fast_io_hosted/process/process/option.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ enum process_mode : ::std::uint_least64_t
88
// *indicates that the process mode has not been evaluated yet
99
new_session = static_cast<::std::uint_least64_t>(1) << 0,
1010
// [POSIX] setsid(), [WINDOWS, WINNT] CREATE_NEW_PROCESS_GROUP (Windows is currently not implemented)
11-
alloc_new_console = static_cast<::std::uint_least64_t>(1) << 1
11+
alloc_new_console = static_cast<::std::uint_least64_t>(1) << 1,
1212
// [WINDOWS, WINNT] CREATE_NEW_CONSOLE (Automatically assign a console to new threads)
13+
argv0_no_appname = static_cast<::std::uint_least64_t>(1) << 2,
14+
// Do not automatically append appname to argv0
1315
};
1416

1517
inline constexpr process_mode operator&(process_mode x, process_mode y) noexcept

0 commit comments

Comments
 (0)