<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt">Also very useful for me would be the output of an mpz_class object into an array (vector<char>). Perhaps there is a way to do this via the ostream operators? My basic problem is: we are already using byte arrays which represent trans-64 bit numbers. I could do a HUGE amount of refactoring of really bad code which manipulates such arrays if I could construct a mpz_class from such an array, do the arithmetic within GMP, output back into an array. The C++ interface seems to character-based I/O only.<br>Thanks for any suggestions.<br>Bob<br><div> </div><font style="color: rgb(127, 0, 63);" size="3"><span style="font-style: italic;"></span></font>----- Original Message ----<br><div style="font-family: times new roman,new york,times,serif; font-size:
12pt;"><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;">From: James Youngman <jay@gnu.org><br>To: David Fang <fang@csl.cornell.edu><br>Cc: gmp-discuss@swox.com; Robert Evans <bobsphysics@yahoo.com><br>Sent: Wednesday, August 13, 2008 9:40:19 AM<br>Subject: Re: Construction From vector<char> ?<br><br>
On Wed, Aug 13, 2008 at 10:55 AM, David Fang <<a ymailto="mailto:fang@csl.cornell.edu" href="mailto:fang@csl.cornell.edu">fang@csl.cornell.edu</a>> wrote:<br><br>> Hi all,<br>><br>> Would anyone object to adding an iterator constructor (similar to<br>> std::string taking a pair of iterators)? I'll just describe the idea below,<br>> I don't have time to provide a full patch at the moment.<br>><br>> First, provide a generic interface function:<br>><br>> /**<br>> \param p pointer to mpz structure to set<br>> \param b beginning of character sequence<br>> \param e one-past-last character iterator (end)<br>> */<br>> template <typename Iter><br>> // inline<br>> int<br>> mpz_init_set_iter(mpz_ptr p, Iter b, Iter e) {<br>> return __mpz_init_set_iter_dispatch(p,b,e,<br>>
typename std::iterator_traits<Iter>::iterator_category());<br>> // dispatcher calls an efficient function for random-access<br>> // iterators, such as char*, vector<char>::iterator,<br>> // string::iterator, ...<br>> // and some less efficient fallback routine for other iterators<br><br>Can't you just do that with a partial specialisation?<br><br>James.<br></div></div></div><br>
</body></html>