Trying to figure out how to allocate memory for arrays using large numbers. I understand that memory cannot be allocated if the data type does not have size_t. Here, for example, I use the boost library (if there are others that are better suited, please advise)

#include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; int128_t v = 68718952447; int128_t *r; r = new int128_t[sqrt(v)]; 

In the last line of the error, I understand, this is due to the fact that int128_t is not size_t. Here's how to get out? I think there probably, when you allocate memory for values, you need to convert to a type where size_t is, but I don’t know how to do it. Tell me, please, how to do it right.

  • And what should take the square root of a type? - Unick
  • @Unick type is smaller, obviously :) - int3
  • mistaken) corrected - Alexander
  • 3
    v.convert_to<size_t>() not working? And where will you get so much memory? - VTT
  • one
    "... that int128_t is not size_t" - what does this phrase mean at all? - AnT

0