mirror of
https://github.com/darlinghq/darling-libcxx.git
synced 2024-11-28 06:10:24 +00:00
[numeric.iota]
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@104719 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c326721e65
commit
ebef7459b2
@ -50,6 +50,9 @@ template <class InputIterator, class OutputIterator, class BinaryOperation>
|
||||
OutputIterator
|
||||
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
|
||||
|
||||
template <class ForwardIterator, class T>
|
||||
void iota(ForwardIterator first, ForwardIterator last, T value);
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
@ -178,6 +181,15 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _ForwardIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
|
||||
{
|
||||
for (; __first != __last; ++__first, ++__value)
|
||||
*__first = __value;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_NUMERIC
|
||||
|
38
test/numerics/numeric.ops/numeric.iota/iota.pass.cpp
Normal file
38
test/numerics/numeric.ops/numeric.iota/iota.pass.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <numeric>
|
||||
|
||||
// template <class ForwardIterator, class T>
|
||||
// void iota(ForwardIterator first, ForwardIterator last, T value);
|
||||
|
||||
#include <numeric>
|
||||
#include <cassert>
|
||||
|
||||
#include "../iterators.h"
|
||||
|
||||
template <class InIter>
|
||||
void
|
||||
test()
|
||||
{
|
||||
int ia[] = {1, 2, 3, 4, 5};
|
||||
int ir[] = {5, 6, 7, 8, 9};
|
||||
const unsigned s = sizeof(ia) / sizeof(ia[0]);
|
||||
std::iota(InIter(ia), InIter(ia+s), 5);
|
||||
for (unsigned i = 0; i < s; ++i)
|
||||
assert(ia[i] == ir[i]);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<forward_iterator<int*> >();
|
||||
test<bidirectional_iterator<int*> >();
|
||||
test<random_access_iterator<int*> >();
|
||||
test<int*>();
|
||||
}
|
Loading…
Reference in New Issue
Block a user