Config.json with Boost:Json

Would not be nice if your json library will tell you what is the actual error ?

Instead of a rather obscure
“source composite size does not match target size” ?

Fear not!

#include "rbk/BoostJson/intrusivedebug.h"
void readConfigFile(...){
auto decoded = bj::try_value_to<Config>(json);
if(decoded.has_error()){
    fmt::print("\n{}\n", BJIntrusive::composeMessage(json, boost::json::value_from(config)));
}

This will require a patched version of the value_to.hpp, and the presence of a few macro, that are on ONLY ACTIVE for that type (in the case above the Config, and yes you should avoid mixing in the same TU other type to avoid the macro is enabled also for them, but is the classic error that will take more effort to trigger than to avoid.)

https://github.com/dublinbranch/rbk/blob/master/BoostJson/intrusivedebug.h