Skip to content

[memory.syn][specialized.algorithms] Prefer trailing returns on complex signatures #6964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[memory.syn][specialized.algorithms] Prefer trailing returns on compl…
…ex signatures

This proposed change follows the observation that when function
template signatures get complicated, especially with long names
for return types, and non-trivial requires clauses, it can be
very hard to spot the function name and return type among the
sea of tokens, in order to start mentally parsing the function.

Here we propose using the trailing return type form of function
declaration in those cases, and apply it consistently to the
special algorithms in the '<memory>' header as a non-trivial
sample size to gauge interest in a more complete PR that would
cover the whole ranges library.
  • Loading branch information
AlisdairM committed May 7, 2024
commit 56fb956015314c0fc0aa6942556c0eafa4e74b0a
73 changes: 38 additions & 35 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11105,10 +11105,10 @@
namespace ranges {
template<@\exposconcept{nothrow-forward-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@<I> S>
requires @\libconcept{default_initializable}@<iter_value_t<I>>
I uninitialized_default_construct(I first, S last);
auto uninitialized_default_construct(I first, S last) -> I;
template<@\exposconcept{nothrow-forward-range}@ R>
requires @\libconcept{default_initializable}@<range_value_t<R>>
borrowed_iterator_t<R> uninitialized_default_construct(R&& r);
auto uninitialized_default_construct(R&& r) -> borrowed_iterator_t<R>;
}
\end{itemdecl}

Expand All @@ -11126,7 +11126,8 @@
\indexlibraryglobal{uninitialized_default_construct_n}%
\begin{itemdecl}
template<class NoThrowForwardIterator, class Size>
NoThrowForwardIterator uninitialized_default_construct_n(NoThrowForwardIterator first, Size n);
auto uninitialized_default_construct_n(NoThrowForwardIterator first, Size n)
-> NoThrowForwardIterator;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -11146,7 +11147,7 @@
namespace ranges {
template<@\exposconcept{nothrow-forward-iterator}@ I>
requires @\libconcept{default_initializable}@<iter_value_t<I>>
I uninitialized_default_construct_n(I first, iter_difference_t<I> n);
auto uninitialized_default_construct_n(I first, iter_difference_t<I> n) -> I;
}
\end{itemdecl}

Expand Down Expand Up @@ -11184,10 +11185,10 @@
namespace ranges {
template<@\exposconcept{nothrow-forward-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@<I> S>
requires @\libconcept{default_initializable}@<iter_value_t<I>>
I uninitialized_value_construct(I first, S last);
auto uninitialized_value_construct(I first, S last) -> I;
template<@\exposconcept{nothrow-forward-range}@ R>
requires @\libconcept{default_initializable}@<range_value_t<R>>
borrowed_iterator_t<R> uninitialized_value_construct(R&& r);
auto uninitialized_value_construct(R&& r) -> borrowed_iterator_t<R>;
}
\end{itemdecl}

Expand All @@ -11205,7 +11206,8 @@
\indexlibraryglobal{uninitialized_value_construct_n}%
\begin{itemdecl}
template<class NoThrowForwardIterator, class Size>
NoThrowForwardIterator uninitialized_value_construct_n(NoThrowForwardIterator first, Size n);
auto uninitialized_value_construct_n(NoThrowForwardIterator first, Size n)
-> NoThrowForwardIterator;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -11225,7 +11227,7 @@
namespace ranges {
template<@\exposconcept{nothrow-forward-iterator}@ I>
requires @\libconcept{default_initializable}@<iter_value_t<I>>
I uninitialized_value_construct_n(I first, iter_difference_t<I> n);
auto uninitialized_value_construct_n(I first, iter_difference_t<I> n) -> I;
}
\end{itemdecl}

Expand All @@ -11244,8 +11246,8 @@
\indexlibraryglobal{uninitialized_copy}%
\begin{itemdecl}
template<class InputIterator, class NoThrowForwardIterator>
NoThrowForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
NoThrowForwardIterator result);
auto uninitialized_copy(InputIterator first, InputIterator last, NoThrowForwardIterator result)
-> NoThrowForwardIterator;
\end{itemdecl}

\begin{itemdescr}
Expand Down Expand Up @@ -11273,12 +11275,12 @@
template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@<I> S1,
@\exposconcept{nothrow-forward-iterator}@ O, @\exposconcept{nothrow-sentinel-for}@<O> S2>
requires @\libconcept{constructible_from}@<iter_value_t<O>, iter_reference_t<I>>
uninitialized_copy_result<I, O>
uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast);
auto uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast)
-> uninitialized_copy_result<I, O>;
template<@\libconcept{input_range}@ IR, @\exposconcept{nothrow-forward-range}@ OR>
requires @\libconcept{constructible_from}@<range_value_t<OR>, range_reference_t<IR>>
uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
uninitialized_copy(IR&& in_range, OR&& out_range);
auto uninitialized_copy(IR&& in_range, OR&& out_range);
-> uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
}
\end{itemdecl}

Expand All @@ -11300,8 +11302,8 @@
\indexlibraryglobal{uninitialized_copy_n}%
\begin{itemdecl}
template<class InputIterator, class Size, class NoThrowForwardIterator>
NoThrowForwardIterator uninitialized_copy_n(InputIterator first, Size n,
NoThrowForwardIterator result);
auto uninitialized_copy_n(InputIterator first, Size n, NoThrowForwardIterator result)
-> NoThrowForwardIterator;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -11328,8 +11330,8 @@
namespace ranges {
template<@\libconcept{input_iterator}@ I, @\exposconcept{nothrow-forward-iterator}@ O, @\exposconcept{nothrow-sentinel-for}@<O> S>
requires @\libconcept{constructible_from}@<iter_value_t<O>, iter_reference_t<I>>
uninitialized_copy_n_result<I, O>
uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
auto uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast)
-> uninitialized_copy_n_result<I, O>;
}
\end{itemdecl}

Expand All @@ -11354,8 +11356,8 @@
\indexlibraryglobal{uninitialized_move}%
\begin{itemdecl}
template<class InputIterator, class NoThrowForwardIterator>
NoThrowForwardIterator uninitialized_move(InputIterator first, InputIterator last,
NoThrowForwardIterator result);
auto uninitialized_move(InputIterator first, InputIterator last, NoThrowForwardIterator result)
-> NoThrowForwardIterator;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -11380,12 +11382,12 @@
template<@\libconcept{input_iterator}@ I, @\libconcept{sentinel_for}@<I> S1,
@\exposconcept{nothrow-forward-iterator}@ O, @\exposconcept{nothrow-sentinel-for}@<O> S2>
requires @\libconcept{constructible_from}@<iter_value_t<O>, iter_rvalue_reference_t<I>>
uninitialized_move_result<I, O>
uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);
auto uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast)
-> uninitialized_move_result<I, O>;
template<@\libconcept{input_range}@ IR, @\exposconcept{nothrow-forward-range}@ OR>
requires @\libconcept{constructible_from}@<range_value_t<OR>, range_rvalue_reference_t<IR>>
uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
uninitialized_move(IR&& in_range, OR&& out_range);
auto uninitialized_move(IR&& in_range, OR&& out_range)
-> uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>;
}
\end{itemdecl}

Expand Down Expand Up @@ -11414,8 +11416,8 @@
\indexlibraryglobal{uninitialized_move_n}%
\begin{itemdecl}
template<class InputIterator, class Size, class NoThrowForwardIterator>
pair<InputIterator, NoThrowForwardIterator>
uninitialized_move_n(InputIterator first, Size n, NoThrowForwardIterator result);
auto uninitialized_move_n(InputIterator first, Size n, NoThrowForwardIterator result)
-> pair<InputIterator, NoThrowForwardIterator>;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -11439,8 +11441,8 @@
namespace ranges {
template<@\libconcept{input_iterator}@ I, @\exposconcept{nothrow-forward-iterator}@ O, @\exposconcept{nothrow-sentinel-for}@<O> S>
requires @\libconcept{constructible_from}@<iter_value_t<O>, iter_rvalue_reference_t<I>>
uninitialized_move_n_result<I, O>
uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
auto uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast)
-> uninitialized_move_n_result<I, O>;
}
\end{itemdecl}

Expand Down Expand Up @@ -11490,10 +11492,10 @@
namespace ranges {
template<@\exposconcept{nothrow-forward-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@<I> S, class T>
requires @\libconcept{constructible_from}@<iter_value_t<I>, const T&>
I uninitialized_fill(I first, S last, const T& x);
auto uninitialized_fill(I first, S last, const T& x) -> I;
template<@\exposconcept{nothrow-forward-range}@ R, class T>
requires @\libconcept{constructible_from}@<range_value_t<R>, const T&>
borrowed_iterator_t<R> uninitialized_fill(R&& r, const T& x);
auto uninitialized_fill(R&& r, const T& x) -> borrowed_iterator_t<R>;
}
\end{itemdecl}

Expand All @@ -11511,7 +11513,8 @@
\indexlibraryglobal{uninitialized_fill_n}%
\begin{itemdecl}
template<class NoThrowForwardIterator, class Size, class T>
NoThrowForwardIterator uninitialized_fill_n(NoThrowForwardIterator first, Size n, const T& x);
auto uninitialized_fill_n(NoThrowForwardIterator first, Size n, const T& x)
-> NoThrowForwardIterator;
\end{itemdecl}

\begin{itemdescr}
Expand All @@ -11531,7 +11534,7 @@
namespace ranges {
template<@\exposconcept{nothrow-forward-iterator}@ I, class T>
requires @\libconcept{constructible_from}@<iter_value_t<I>, const T&>
I uninitialized_fill_n(I first, iter_difference_t<I> n, const T& x);
auto uninitialized_fill_n(I first, iter_difference_t<I> n, const T& x) -> I;
}
\end{itemdecl}

Expand Down Expand Up @@ -11615,10 +11618,10 @@
namespace ranges {
template<@\exposconcept{nothrow-input-iterator}@ I, @\exposconcept{nothrow-sentinel-for}@<I> S>
requires @\libconcept{destructible}@<iter_value_t<I>>
constexpr I destroy(I first, S last) noexcept;
constexpr auto destroy(I first, S last) noexcept -> I;
template<@\exposconcept{nothrow-input-range}@ R>
requires @\libconcept{destructible}@<range_value_t<R>>
constexpr borrowed_iterator_t<R> destroy(R&& r) noexcept;
constexpr auto destroy(R&& r) -> borrowed_iterator_t<R> noexcept;
}
\end{itemdecl}

Expand Down Expand Up @@ -11655,7 +11658,7 @@
namespace ranges {
template<@\exposconcept{nothrow-input-iterator}@ I>
requires @\libconcept{destructible}@<iter_value_t<I>>
constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept;
constexpr auto destroy_n(I first, iter_difference_t<I> n) -> I noexcept;
}
\end{itemdecl}

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy