Open rbrugo opened 4 years ago
I like this idea.
+1 from transform_apply of some sort.
Some people suggest create wrappers: https://stackoverflow.com/a/65855073, but having this as a ranges "vocabulary" view would be awesome.
Same for filtering. Currently I have:
//find first empty slot in the grid, starting from top left, moving in rows to the right
for (const auto& [row, column]: rv::cartesian_product(rv::indices(gridHeight), rv::indices(gridWidth))
| rv::filter([this](const auto& tuple){ const auto [row, column] = tuple; return !containsSlot(column, row); })) {
return QPoint{column, row};
}
So instead of
rv::filter([this](const auto& tuple){ const auto [row, column] = tuple; return !containsSlot(column, row); }
It would be nice to have something like this:
rv::filter_apply([this](int row, int column){ return !containsSlot(column, row); }
In light of that, rather than adding N view
_apply
, it'd be better to just have a predicate wrapper applied(f)
that does std::apply(f,
e
)
.
So it would look like this?
| filter(unpack(mylambda)) | ...
Hi, I could be wrong, but currently if I want to transform a tuple-like object I have to do something like
I think it would be nice if it were possible to write
by having an overload for
transform_view::operator()
which tries tostd::apply
if it is not possible toINVOKE
, or a completely new view if that is not possible