YexuanXiao / basic_json

A modern C++ library for working with JSON data, aims to provide full support for the JSON standard, as well as allowing users to customize and extend the library according to their needs. The library offers a user-friendly and C++-idiomatic API, without compromising on performance.
Creative Commons Zero v1.0 Universal
8 stars 2 forks source link

`constexpr` issues #3

Open frederick-vs-ja opened 3 months ago

frederick-vs-ja commented 3 months ago
  1. The current implementation reinterpret_casts between node_type and json_type. reinterpret_cast is very likely to (although not always) result in UB here, and it always breaks constant evaluation.
  2. stor_t stores void* pointers, and static_cast from it to (the correct) concrete pointer types isn't constant-evaluation-compatible until C++26. Same for several occurences of placement-new.
  3. std::map is currently used as default template arguments but not yet constexpr. Not sure whether there should be a constexpr variant of std::map to make basic_json fully usable in constant evaluation by default at this moment.
frederick-vs-ja commented 3 months ago

It seems that type erasure is desired for node types, which is incompatible with constant evaluation until C++26.

frederick-vs-ja commented 3 months ago

Bullet 1 is resolved and bullet 2 is ~mute~ moot. So the remaining work seems to be adding a constexpr map container for test or product...

Edit: See also WG21 P3372.