1//
2// immer: immutable data structures for C++
3// Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente
4//
5// This software is distributed under the Boost Software License, Version 1.0.
6// See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
7//
8
9#include <immer/vector.hpp>
10#include <immer/vector_transient.hpp>
11#include <iostream>
12#include <algorithm>
13
14// include:myiota/start
15immer::vector<int> myiota(immer::vector<int> v, int first, int last)
16{
17 auto t = v.transient();
18 std::generate_n(std::back_inserter(t),
19 last - first,
20 [&] { return first++; });
21 return t.persistent();
22}
23// include:myiota/end
24
25int main()
26{
27 auto v = myiota({}, 0, 100);
28 std::copy(v.begin(), v.end(),
29 std::ostream_iterator<int>{
30 std::cout, "\n"});
31}
32