A sketch of how tqdm.cpp would be used
CrazyPython opened this issue · 8 comments
To maintain simplicity, tqdm.cpp
should support iterate-range:
for (auto&& item : tqdm::tqdm()) {
...
}
- Provide an equivalent to
for (int i; i < x; ++i)
in the form oftrange
that supports iterate-range. C++ is inherently different than python, sotrange
will be used much more often. tqdm::tqdm
is a little bit redundant. Is there an elegant way to solve this?
yes, working on this. there's only one correct way to do this; no point
discussing it here until I've pushed the stub.
But since you've opened this issue:
- namespaces
- classes and structures
- forward_iterator_tag
namespace tqdm{
template <typename _Iterator>
class tqdm{
public:
tqdm(_Iterator start, _Iterator end);
tqdm(_Iterator start, size_t total);
typedef ForwardIterator<_Iterator> iterator;
typedef ForwardIterator<const _Iterator> const_iterator;
};
}
tqdm::tqdm
needs to be a function, not a class, so that the template parameters don't have to be specified.
tqdm::TqdmIterable<>
can be the class - we're definitely going to need multiple classes in order to support all the python functionality, and I want tqdm::Tqdm
for the manual case.
@o11c How would tqdm::tqdm
work as a function?
trange
can be a function too.
@o11c I don't understand how tqdm::tqdm
would be a function - what would it return?
@casperdcl @o11c make a PR to the dev branch and let us review it
@o11c yes, I'm aiming for a class Tqdm
with a function helper tqdm
which returns an instance of the class. the class itself will be forward iterator. in future we may want to allow bidirectional iterators and accordingly backtrack ETA and stats (haha)
in terms of range
I think (after much pondering) that it's best to implement a custom range iterator which spoofs a vector - essentially a generator
implemented in dev, master as per this discussion (function tqdm::tqdm
, tqdm::range
, class tqdm::Tqdm
)