Boost logo

Boost Users :

From: Claudio La Rosa (claudio.larosa74_at_[hidden])
Date: 2021-08-03 16:53:48


My array have only 3 elements, but I indexed it with an modulo operation (%) that use a uint128_t value. The result of modulo operation is a uint128_t value type.

But well, I now use with success a standard cast for obtain a valid index type value!
Thanks!

Da: John Maddock via Boost-users
Inviato: martedì 3 agosto 2021 18:40
A: Claudio La Rosa via Boost-users
Cc: John Maddock
Oggetto: Re: [Boost-users] Boost multiprecision as array index

On 03/08/2021 07:34, Claudio La Rosa via Boost-users wrote:
>
> Hi to all,
>
> I unsuccessfully  tried to use a boost multiprecision variable
> (object?) as index of an array.
>
> Int myArray[100];
>
> uint128_t index = 23;
>
> int value = myArray[index];
>
> This code don’t work.
>
> There is a way for to use a multiprecision as index of an array?
>
You would need to explicitly cast the variable to a std::size_t.

But I would rather question the wisdom of using a multiprecision type in
that context?

John.

-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
https://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net