Header utils.hpp
<class InputIt, class Fn> it_transform
Iterator to transform a range.
it_transform(InputIt begin, InputIt end, Fn fn)
Constructor.
class iterator
iterator begin()
iterator end()
In general, an input iterator
.
void reset_src_iterator(InputIt begin, InputIt end)
Provide a new range of iterator so it can be iterated again with the same transformer function.
This helper can be used to do a select operation to create a new pair of iterators based on existing iterators that are inconvenient to modify:
int arr[] = {1, 0, 0, 0, 2, 9};
it_transform mapped {std::begin(arr), std::end(arr), [](int i) -> const char * {
return i ? "true" : "nil";
}};
auto tab = make_tabulate<6, 6>(
static_ansi_style_options_none,
tabulate_title_row_args{std::begin(arr), std::end(arr), static_ansi_style_options_none},
tabulate_elem_row_args{std::begin(mapped), static_ansi_style_options_none}
);
for (auto sv : tab) {
puts(sv.data());
}
The output is:
+------------------------------------+
| 1 0 0 0 2 9 |
+------------------------------------+
| true nil nil nil true true |
+------------------------------------+