-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2388,6 +2388,41 @@ _FwdIt2 replace_copy_if(_ExPo&&, _FwdIt1 _First, _FwdIt1 _Last, _FwdIt2 _Dest, _ | |
} | ||
#endif // _HAS_CXX17 | ||
|
||
#ifdef __cpp_lib_concepts | ||
namespace ranges { | ||
template <class _FwdIt, class _T> | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
// VARIABLE ranges::fill | ||
class _Fill_fn : private _Not_quite_object { | ||
public: | ||
using _Not_quite_object::_Not_quite_object; | ||
|
||
// clang-format off | ||
template <class _T, output_iterator<const _T&> _O, sentinel_for<_O> _S> | ||
constexpr _O operator()(_O _First, _S _Last, const _T& _Value) const { | ||
This comment has been minimized.
Sorry, something went wrong.
miscco
Contributor
|
||
_Adl_verify_range(_First, _Last); | ||
auto _UFirst = _Get_unwrapped(_STD move(_First)); | ||
auto _ULast = _Get_unwrapped(_STD move(_Last)); | ||
This comment has been minimized.
Sorry, something went wrong.
miscco
Contributor
|
||
while (_UFirst != _ULast) { | ||
*_UFirst = _Value; | ||
++_UFirst; | ||
} | ||
|
||
_Seek_wrapped(_First, _STD move(_UFirst)); | ||
return _First; | ||
} | ||
|
||
template <class _T, output_range<const _T&> _Rng> | ||
constexpr borrowed_iterator_t<_Rng> operator()(_Rng&& _Range, const _T& _Value) const { | ||
return (*this)(_RANGES begin(_Range), _RANGES end(_Range), _Value) | ||
} | ||
// clang-format on | ||
}; | ||
|
||
inline constexpr _Fill_fn fill{_Not_quite_object::_Construct_tag{}}; | ||
} // namespace ranges | ||
#endif // __cpp_lib_concepts | ||
|
||
// FUNCTION TEMPLATE generate | ||
template <class _FwdIt, class _Fn> | ||
_CONSTEXPR20 void generate(_FwdIt _First, _FwdIt _Last, _Fn _Func) { // replace [_First, _Last) with _Func() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
RUNALL_INCLUDE ..\concepts_matrix.lst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include <algorithm> | ||
#include <cassert> | ||
#include <concepts> | ||
#include <ranges> | ||
#include <utility> | ||
#include <range_algorithm_support.hpp> | ||
|
||
constexpr void smoke_test() { | ||
using ranges::fill, ranges::iterator_t; | ||
using std::same_as; | ||
|
||
int output[] = {13, 42, 1367}; | ||
{ | ||
const int value = 7; | ||
auto result = fill(output.begin(), output.end(), value); | ||
for (int i = 0; i < 3; ++i) { | ||
assert(output[i] == 7); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
assert(result == output.end()); | ||
} | ||
} | ||
|
||
int main() { | ||
// STATIC_ASSERT((smoke_test(), true)); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
smoke_test(); | ||
} | ||
|
||
struct instantiator { | ||
template <class In> | ||
static void call(In&& in = {}) { | ||
(void) ranges::fill(in, SOMETHING); | ||
(void) ranges::fill(ranges::begin(in), ranges::end(in), SOMETHING); | ||
} | ||
}; | ||
|
||
template void test_in_out<instantiator>(); |
Oops