Description
I've opened a json file and parsed it with this library and I wrote this:
std::string connection_config = std::format("host={} port={} dbname={} user={} password='{}'", db_config.at("host"),
db_config.at("port"), db_config.at("dbname"), db_config.at("user"),
db_config.at("password"));
However I get this error:
In template: call to deleted constructor of 'typename format_context::formatter_type<basic_json<std::map, std::vector, string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>>>' (aka 'formatter<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>>, char>')
Note of interest: this only happens with std::format, fmt::format is fine
Reproduction steps
Open a file with std::ifstream
Pass the file object to nlohmann::json
Parse the json file
Try to format it using std::format
Expected vs. actual results
Expected result: The json array being formatted properly
Actual result: error
Minimal code example
auto db_config_file = std::ifstream {"~/.reacatio/database.json"};
json db_config = json::parse(db_config_file);
db_config_file.close();
std::string connection_config = std::format("host={} port={} dbname={} user={} password='{}'", db_config.at("host"),
db_config.at("port"), db_config.at("dbname"), db_config.at("user"),
db_config.at("password"));
Error messages
In template: call to deleted constructor of 'typename format_context::formatter_type<basic_json<std::map, std::vector, string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>>>' (aka 'formatter<nlohmann::basic_json<std::map, std::vector, std::string, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>>, char>')
Compiler and operating system
clang 17, linux
Library version
3.11.2
Validation
Description
I've opened a json file and parsed it with this library and I wrote this:
However I get this error:
Note of interest: this only happens with std::format, fmt::format is fine
Reproduction steps
Open a file with std::ifstream
Pass the file object to nlohmann::json
Parse the json file
Try to format it using std::format
Expected vs. actual results
Expected result: The json array being formatted properly
Actual result: error
Minimal code example
auto db_config_file = std::ifstream {"~/.reacatio/database.json"}; json db_config = json::parse(db_config_file); db_config_file.close(); std::string connection_config = std::format("host={} port={} dbname={} user={} password='{}'", db_config.at("host"), db_config.at("port"), db_config.at("dbname"), db_config.at("user"), db_config.at("password"));Error messages
Compiler and operating system
clang 17, linux
Library version
3.11.2
Validation
developbranch is used.