1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template<ForwardIterator Iter, class T>
12 // requires OutputIterator<Iter, Iter::reference>
13 // && OutputIterator<Iter, const T&>
14 // && HasEqualTo<Iter::value_type, T>
15 // constexpr void // constexpr after C++17
16 // replace(Iter first, Iter last, const T& old_value, const T& new_value);
21 #include "test_macros.h"
22 #include "test_iterators.h"
26 TEST_CONSTEXPR
bool test_constexpr() {
27 int ia
[] = {0, 1, 2, 3, 4};
28 const int expected
[] = {0, 1, 5, 3, 4};
30 std::replace(std::begin(ia
), std::end(ia
), 2, 5);
31 return std::equal(std::begin(ia
), std::end(ia
), std::begin(expected
), std::end(expected
))
40 int ia
[] = {0, 1, 2, 3, 4};
41 const unsigned sa
= sizeof(ia
)/sizeof(ia
[0]);
42 std::replace(Iter(ia
), Iter(ia
+sa
), 2, 5);
52 test
<forward_iterator
<int*> >();
53 test
<bidirectional_iterator
<int*> >();
54 test
<random_access_iterator
<int*> >();
58 static_assert(test_constexpr());