Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

rational_adaptor

namespace boost{ namespace multiprecision{

template <class IntBackend>
class rational_adpater;

}}

The class template rational_adaptor is a back-end for number which converts any existing integer back-end into a rational-number back-end.

So for example, given an integer back-end type MyIntegerBackend, the use would be something like:

typedef number<MyIntegerBackend>                    MyInt;
typedef number<rational_adaptor<MyIntegerBackend> > MyRational;

MyRational r = 2;
r /= 3;
MyInt i = numerator(r);
assert(i == 2);

PrevUpHomeNext