nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
43.41k stars 6.76k forks source link

Unable to use gnu mpz types for NumberIntegerType #3578

Open eric-wieser opened 2 years ago

eric-wieser commented 2 years ago

Description

I was hoping it would be possible to set NumberIntegerType and NumberUnsignedType (putting aside #2573 for now) to an arbitrary precision integer type ("big integers"), such as on wrapper types around the gnu multiple precision arithmetic library.

Unfortunately, this is not permitted as json_value is a C-style tagged union that doesn't permit any of its types to have non-trivial destructors/move constructors etc; and mpz is stored on the heap.

I understand this is quite a big ask, but I thought it was worth having an issue explicitly mentioning big integers since I wasn't able to find an existing one via search.

Reproduction steps

Attempt to use some numeric heap type for the numeric type parameters. I'm afraid I don't have a trivial example to hand without external dependencies.

Expected vs. actual results

In an ideal world, I would expect everthing to just work. Instead, I get compiler errors about deleted operators on json_value due to it being a union of non trivial types.

Minimal code example

No response

Error messages

No response

Compiler and operating system

N/A

Library version

d4daaa897f48bf7bb2f96b46b84e49f32dd11daf

Validation

sjunges commented 2 years ago

Just FYI: This https://github.com/moves-rwth/storm/commits/master/resources/3rdparty/modernjson/src diff shows some of the changes that were necessary to an earlier version of modernjson to support GMPs instead of doubles.

We are in the progress of updating modernjson and applying the patch is a bit painful ;-)