Boost logo

Boost :

Subject: Re: [boost] [multiprecision] Creation from a range
From: Fernando Pelliccioni (fpelliccioni_at_[hidden])
Date: 2016-01-06 11:10:07


On Tue, Jan 5, 2016 at 12:50 AM, Damian Vicino <damian.vicino_at_[hidden]>
wrote:

> > Is there any way to create an Integer (or a number) from a range (bounded
> > or counted)?; or from a string_view (string_ref)?
> >
> > Roughly speaking, something like:
> >
> > XintXXX_t make_from_bounded_range(I f, I l);
> > XintXXX_t make_from_counted_range(I f, size_t n);
>
> What are the semantics?
>

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.

> Is this a measure? Like an integer distance between borders?
>

I don't understand these questions. The numbers could be anything.

>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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