Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
#include <array>
#include <iostream>
#include <string>
#include <vector>
auto main() -> int {
using namespace eagine::memory;
std::array<const std::string, 4> list{{"foo", "baz", "qux", "bar"}};
std::vector<std::size_t> index(list.size());
generate(
cover(index), [i{std::size_t{0}}]()
mutable {
return i++; });
for(auto i : index) {
std::cout << list[i] << std::endl;
}
for(auto i : index) {
std::cout << list[i] << std::endl;
}
return 0;
}
Common code is placed in this namespace.
Definition: eagine.hpp:21
static auto make_index(basic_span< T, P, S > spn, basic_span< I, PI, SI > idx, Compare compare) -> bool
Makes the index of a span according to compare, into another span.
Definition: span_algo.hpp:641
static constexpr auto cover(T *addr, S size) noexcept -> span_if_mutable< T >
Creates a span starting at the specified pointer and specified length.
Definition: span.hpp:465
static constexpr auto view(T *addr, S size) noexcept -> const_span< T >
Creates a view starting at the specified pointer and specified length.
Definition: span.hpp:458
static auto generate(basic_span< T, P, S > spn, Generator gen) -> basic_span< T, P, S >
Fills a span with elements generated by a generator callable.
Definition: span_algo.hpp:584