adiar
adiar copied to clipboard
Overload API with Ranges
Currently we provide generator and iterator overloads for many algorithms. Yet, if possible we should also provide some container/range based input.
For example, one would hope to write something like the following:
std::vector<int> vars;
for (int i = 0; i < varcount; ++i) {
vars.push_back(i);
}
f = adiar::bdd_exists(f, vars);
Additional context This was requested by Anna Blume Jakobsen while browsing through the documentation.
Doing so might actually just be as little as this (and adding a few sanity unit checks)
template<Range>
__bdd
exists(const bdd &f, Range r)
{ return exists(f, r.rbegin(), r.rend()); }
The only complications might be overload resolution due to the implicit conversion construction of generator<bdd::label_type>
as we also had to do for bdd_and(...)
.
- If we used C++20, this would be easy to solve with concepts. Yet, with C++17 we are in trouble (but we can try with sfinae).
- The simplest (but quite ugly) solution would be to place it in a new
ranges
submodule; this also aligns with std. But, I would consider this only a last resort.