Specifying precision in vector<mpf_class>?

Felix E. Klee felix.klee.gmp@gmx.net
Wed, 16 Jul 2003 10:38:24 +0200


On Wednesday 16 July 2003 01:46, Kevin Ryde wrote:
> > what's the easiest way to create a std::vector of mpf_class with a
> > certain precision PREC (which is not the default precision)? I tried
> > subclassing mpf_class but as explained in the online help this leads to
> > much trouble because one has to redefine many operators.
>
> It'd be nice if we could make that easier.
>
> > If there's no easy way: Has someone considered adding the precision as
> > a template parameter? That way one could write
> > "std::vector<mpf_class<PREC> > some_vector".
>
> I'm not up with how vector works, but can you specify a constructor
> call for the elements?  That'd allow you to put a precision there.

Ah, yes you can specify a default value and then all elements are 
initialized with the copy constructor. I didn't think about this solution 
when I wrote the message. So, the issue seems to be closed for me. However, 
it might still be nice to be able to specify the precision as a template 
parameter since then one could write stuff like 
    typedef mpf_class<128> very_long_double;

Felix

-- 
To contact me in private don't reply but send mail to
    felix DOT klee AT inka DOT de