templatized output adapters#2173
Conversation
|
A comment in the reddit post about the 3.8.0 release caught my attention:
This would actually be easy to fix by having the |
I also saw that comment. I think we can also implement a small recursive function that collects and combines the individual hashes. Using the output of |
FYI: I tried to fix this in #2269 - comments welcome! |
|
@FrancoisChabot Any idea how to proceed here? |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is a draft Fix for #2172.
The
output_adapter_protocolis replaced by templatizing the serializer on the output adapter.The PR also adds the
basic_json::dump_to()method, which allows for outputing json to arbitrary user-defined sinks.Valid sinks are:
std::basic_string<>, This will append to the string very efficientlystd::iterator_traits<T>::iterator_tag == std::output_iterator_tagstd::back_inserter(T)works. In practice, that means having apush_back(char)function.If all else fails, the output will be assumed to be:
put(c)andwrite(ptr, len))TODO:
Pull request checklist
Read the Contribution Guidelines for detailed information.
include/nlohmanndirectory, runmake amalgamateto create the single-header filesingle_include/nlohmann/json.hpp. The whole process is described here.