From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH 2/2] libstdc++: Implement ranges [specialized.algorithms]
Date: Thu, 13 Feb 2020 16:12:00 -0000 [thread overview]
Message-ID: <20200213161245.GF9441@redhat.com> (raw)
In-Reply-To: <20200212204107.4124217-2-ppalka@redhat.com>
On 12/02/20 15:41 -0500, Patrick Palka wrote:
>This implements all the ranges members defined in [specialized.algorithms]:
>
> ranges::uninitialized_default_construct
> ranges::uninitialized_value_construct
> ranges::uninitialized_copy
> ranges::uninitialized_copy_n
> ranges::uninitialized_move
> ranges::uninitialized_move_n
> ranges::uninitialized_fill
> ranges::uninitialized_fill_n
> ranges::construct_at
> ranges::destroy_at
> ranges::destroy
>
>It also implements (hopefully correctly) the "obvious" optimizations for these
>algos, namely that if the output range has a trivial value type and if the
>appropriate operation won't throw then we can dispatch to the standard ranges
>version of the algorithm which will then potentially enable further
>optimizations.
>
>libstdc++-v3/ChangeLog:
>
> * include/Makefile.am: Add <bits/ranges_uninitialized.h>.
> * include/Makefile.in: Regenerate.
> * include/bits/ranges_uninitialized.h: New header.
> * include/std/memory: Include it.
> * testsuite/20_util/specialized_algorithms/destroy/constrained.cc: New
> test.
> * .../uninitialized_copy/constrained.cc: New test.
> * .../uninitialized_default_construct/constrained.cc: New test.
> * .../uninitialized_fill/constrained.cc: New test.
> * .../uninitialized_move/constrained.cc: New test.
> * .../uninitialized_value_construct/constrained.cc: New test.
>+ template<__detail::__nothrow_input_iterator _Iter,
>+ __detail::__nothrow_sentinel<_Iter> _Sent>
>+ requires destructible<iter_value_t<_Iter>>
>+ constexpr _Iter
>+ destroy(_Iter __first, _Sent __last) noexcept
>+ {
>+ if constexpr (is_trivially_destructible_v<iter_value_t<_Iter>>)
>+ return ranges::next(__first, __last);
>+ else
>+ {
>+ for (; __first != __last; ++__first)
>+ ranges::destroy_at(addressof(*__first));
This should be std::__addressof
>+ return __first;
>+ }
>+ }
>+
>+ template<__detail::__nothrow_input_range _Range>
>+ requires destructible<range_value_t<_Range>>
>+ constexpr safe_iterator_t<_Range>
>+ destroy(_Range&& __r) noexcept
>+ { return ranges::destroy(ranges::begin(__r), ranges::end(__r)); }
>+
>+ template<__detail::__nothrow_input_iterator _Iter>
>+ requires destructible<iter_value_t<_Iter>>
>+ constexpr _Iter
>+ destroy_n(_Iter __first, iter_difference_t<_Iter> __n) noexcept
>+ {
>+ if constexpr (is_trivially_destructible_v<iter_value_t<_Iter>>)
>+ return ranges::next(__first, __n);
>+ else
>+ {
>+ for (; __n > 0; ++__first, (void)--__n)
>+ ranges::destroy_at(addressof(*__first));
Same here.
OK for master with those two adjustments.
next prev parent reply other threads:[~2020-02-13 16:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 20:42 [PATCH 1/2] libstdc++: Move some ranges algos to a new header <bits/ranges_algobase.h> Patrick Palka
2020-02-12 20:42 ` [PATCH 2/2] libstdc++: Implement ranges [specialized.algorithms] Patrick Palka
2020-02-13 16:12 ` Jonathan Wakely [this message]
2020-02-13 20:46 ` Patrick Palka
2020-02-13 12:20 ` [PATCH 1/2] libstdc++: Move some ranges algos to a new header <bits/ranges_algobase.h> Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200213161245.GF9441@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).