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

eagine/interleaved_call.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 <iostream>
auto main() -> int {
using namespace eagine;
using std::cout;
using v = string_view;
auto fn1 =
interleaved_call([](int i) { cout << i; }, []() { cout << ", "; });
for(int i = 0; i < 20; ++i) {
fn1(i);
}
cout << std::endl;
auto fn2 = interleaved_call(
[](string_view s) { cout << s; }, []() { cout << "}{"; });
cout << '{';
for(auto name : view(
{v("January"),
v("February"),
v("March"),
v("April"),
v("May"),
v("June"),
v("July"),
v("August"),
v("September"),
v("October"),
v("November"),
v("December")})) {
fn2(name);
}
cout << '}' << std::endl;
return 0;
}
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
Common code is placed in this namespace.
Definition: eagine.hpp:21
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
Callable class that interleaves calls to a function with a separator function.
Definition: interleaved_call.hpp:20

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