OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine/make_index.cpp

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 <eagine/span.hpp>
#include <array>
#include <iostream>
#include <string>
#include <vector>
auto main() -> int {
using namespace eagine;
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++; });
make_index(view(list), cover(index));
for(auto i : index) {
std::cout << list[i] << std::endl;
}
make_index(view(list), cover(index), std::greater<>());
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

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).