From 4fa94d45b33d2b2774c84c13cbd3654866c94910 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Tue, 4 Aug 2020 20:08:58 +0900 Subject: [PATCH] fix: use const char* instead of &char[N] to enable to pass char*, not only string literal --- toml/parser.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/toml/parser.hpp b/toml/parser.hpp index 7ef196a..86c920b 100644 --- a/toml/parser.hpp +++ b/toml/parser.hpp @@ -2089,17 +2089,16 @@ basic_value parse(const std::string& fname) // This function just forwards `parse("filename.toml")` to std::string version // to avoid the ambiguity in overload resolution. // -// Both std::string and std::filesystem::path are convertible from const char[]. +// Both std::string and std::filesystem::path are convertible from const char*. // Without this, both parse(std::string) and parse(std::filesystem::path) // matches to parse("filename.toml"). This breaks the existing code. // -// This function exactly matches to the invokation with string literal. +// This function exactly matches to the invokation with c-string. // So this function is preferred than others and the ambiguity disappears. template class Table = std::unordered_map, - template class Array = std::vector, - std::size_t N> -basic_value parse(const char (&fname)[N]) + template class Array = std::vector> +basic_value parse(const char* fname) { return parse(std::string(fname)); }