Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#9235 closed Feature Requests (fixed)

Construction from binary data — at Version 3

Reported by: Domagoj Šarić Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.54.0 Severity: Optimization
Keywords: Cc:

Description (last modified by Domagoj Šarić)

I didn't find a way to directly construct fixed sized cpp_int from existing binary data (a static array, for example an RSA key hardcoded into a .cpp after being generated with OpenSSL)... I had to resort to either using the from-string constructor or inserting the data byte by byte with 8 bit shifts and or-ing in a loop both of which are ugly and inefficient: https://svn.boost.org/trac/boost/ticket/9233 https://svn.boost.org/trac/boost/ticket/9234 https://svn.boost.org/trac/boost/ticket/9243 ...

Ideally it would be possible to create static fixed size numbers as one creates PODs, without a dynamic initializer being created by the compiler..

Change History (3)

comment:1 by John Maddock, 9 years ago

This is supported.... but only in C++11 compliant compilers (ie not VC++ I'm afraid at present). See: http://www.boost.org/doc/libs/1_54_0/libs/multiprecision/doc/html/boost_multiprecision/tut/lits.html

When supported though, the integer is compile-time constructed from the data with no runtime overhead at all.

Otherwise I'd strongly recommend you use the "construct from hexadecimal string" method, as that runtime code is well optimized (I hope!).

comment:2 by John Maddock, 9 years ago

Resolution: wontfix
Status: newclosed

comment:3 by Domagoj Šarić, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.