chsvlib
chsv helper source code
chsvmemex\make_generating_input_iterator.cpp

Demonstrates usage of the make_generating_input_iterator function.

#include <vector>
#include <iterator>
using namespace Chusov::Memory;
std::vector<unsigned> fill_generate(std::size_t count)
{
std::vector<unsigned> v;
unsigned val = 0;
std::copy_n(make_generating_input_iterator([&val]() mutable {return ++val;}), count, std::back_inserter(v));
return v;
}
#include <iostream>
int main(int argc, char** argv)
{
auto v = fill_generate(10);
for (const auto& elem:v)
std::cout << elem << ' ';
std::cout << '\n';
return 0;
}
/*
Output:
>1 2 3 4 5 6 7 8 9 10
>
*/
Advanced functionality and C++ objects for working with memory.
auto make_generating_input_iterator(GeneratingFunctor generator)
A helper function used to create a generating iterator of type generating_input_iterator with deducti...
Definition: chsvmemex.h:833
OutputIterator copy_n(InputIterator input, std::size_t size, OutputIterator output) noexcept(std::is_nothrow_copy_assignable< typename std::iterator_traits< OutputIterator >::value_type >::value)
Copy-assigns a given number of elements starting from one referred to by an input iterator to a place...
Definition: chsvmemex.h:2291
A namespace of functions and components used to work with memory.
Definition: chsvmem.h:71