saxbophone / arby

Arbitrary precision arithmetic in C++, even at compile-time
https://saxbophone.com/arby/
Mozilla Public License 2.0
8 stars 1 forks source link

Interval<T> type for return results of ilog, ipow, iroot #136

Closed saxbophone closed 1 year ago

saxbophone commented 1 year ago

This may be more idiomatic in the long run than passing around std::pair<> objects.

We can even call the members floor and ceil for maximum idiomaticness.

Also should provide a templated converting constructor for converting from instances of this template on other types, so we can take advantage of say automatic casting from Nat <-> Int without needing to special-case them.

This should naturally, support the same tuple item-getter interface of std::pair and std::tuple, so we can still use our replacement type with structured bindings. With this in mind, we would do best to not change our existing tests to use Interval explicitly, and instead keep the structured bindings usage: https://stackoverflow.com/a/37188019/6177253

saxbophone commented 1 year ago

Consider using interval syntax for std::cout: https://en.wikipedia.org/wiki/Interval_(mathematics)#Terminology

saxbophone commented 1 year ago

Here's some helpful info on how to support the same interface that tuple/pair use: https://dominikberner.ch/structured-bindings/