Namespaces
Variants
Views
Actions

Talk:cpp/algorithm/adjacent difference

From cppreference.com
< Talk:cpp‎ | algorithm
Revision as of 07:11, 28 April 2018 by Fruderica (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In 1,3) it's stated that:

The input ranges may overlap, but cannot be identical: the behavior is undefined if first==d_first

According to this statement, the first example in this page invokes UB:

   std::vector<int> v{2, 4, 6, 8, 10, 12, 14, 16, 18, 20};
   std::adjacent_difference(v.begin(), v.end(), v.begin());

The latest draft (N4659, § 29.8.11, 6th point) explicitly allows (first == d_first).

--85.150.177.92 10:07, 15 August 2017 (PDT) Ennio Barbaro

[edit] constexpr has not been added to adjacent_difference in n4741

Is it OK to add constexpr to std::adjacent_difference in the article? - Fruderica (talk) 08:11, 28 April 2018 (PDT)