Boost logo

Boost :

Subject: Re: [boost] [multiprecision] Creation from a range
From: John Maddock (jz.maddock_at_[hidden])
Date: 2016-01-06 11:53:56


> I want to extract integers from a range (range of characters). Consider:
>
> char buff[] = "12345 67890"; auto a =
> make_from_bounded_range<int128_t>(buff, buff + 5); auto b =
> make_from_counted_range<int128_t>(buff, 5); auto c =
> make_from_bounded_range<int128_t>(buff + 6, buff + 6 + 5); auto d =
> make_from_counted_range<int128_t>(buff + 6, 5); cout << a << '\n' << b <<
> '\n' << c << '\n' << d << '\n';
>
> Prints:
> 12345
> 12345
> 67890
> 67890
>
> How can I do this today with Boost multiprecision?
> I don't want to copy characters to a temporal buffer.

I would say this is a string-stream problem - what you want to do is
create a stream which doesn't copy the data - there's an example here:
https://github.com/boostorg/regex/blob/develop/include/boost/regex/v4/cpp_regex_traits.hpp#L75
which you could cut and paste to do the job?

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk