stephenberry / glaze

Extremely fast, in memory, JSON and interface library for modern C++
MIT License
1.22k stars 121 forks source link

Support of custom string #1340

Closed sjanel closed 1 month ago

sjanel commented 1 month ago

I would like to use this library with a custom string implementation as drop-down replacement of std::string. Is it possible to do that currently ?

If not, would it be possible to define a "writable buffer of char" as returned by value type custom mapping to make it work ? It could be a span<char>, or something else maybe.

stephenberry commented 1 month ago

Glaze uses C++20 concepts to handle different types. If your string class has a similar API to a std::string then it should still work. It should work as long as it has size(), resize(), and data() (to get the underlying buffer).

If you run into any issues, let me know.

sjanel commented 1 month ago

Thanks a lot! Indeed it seems to work out of the box. What about explaining it in the documentation?

stephenberry commented 1 month ago

Nice. And thanks for the suggestion. I'll add some documentation notes about this.