C++ Logo

std-discussion

Advanced search

Re: may std:partial_sum change elements of the specified range?

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Tue, 22 Nov 2022 23:10:40 +0000
On Tue, 22 Nov 2022 at 22:07, Vladimir Grigoriev via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> Consider the following code snippet
>
> int a[] = { 1, 2, 3, 4, 5 };
>
> std::partial_sum( std::begin( a ), std::end( a ), std::begin( a ) );
>
> Is it a well-formed code?
>

Explicitly, yes.

> *Remarks*: result may be equal to first.

http://eel.is/c++draft/numeric.ops#partial.sum-6

(Though see LWG 3487:
https://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#3487 )


> With best regards
> (Vlad from Moscow)
> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or
> http://ru.stackoverflow.com
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

Received on 2022-11-22 23:10:54