mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
fix: use const char* instead of &char[N]
to enable to pass char*, not only string literal
This commit is contained in:
@@ -2089,17 +2089,16 @@ basic_value<Comment, Table, Array> parse(const std::string& fname)
|
|||||||
// This function just forwards `parse("filename.toml")` to std::string version
|
// This function just forwards `parse("filename.toml")` to std::string version
|
||||||
// to avoid the ambiguity in overload resolution.
|
// 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)
|
// Without this, both parse(std::string) and parse(std::filesystem::path)
|
||||||
// matches to parse("filename.toml"). This breaks the existing code.
|
// 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.
|
// So this function is preferred than others and the ambiguity disappears.
|
||||||
template<typename Comment = ::toml::discard_comments,
|
template<typename Comment = ::toml::discard_comments,
|
||||||
template<typename ...> class Table = std::unordered_map,
|
template<typename ...> class Table = std::unordered_map,
|
||||||
template<typename ...> class Array = std::vector,
|
template<typename ...> class Array = std::vector>
|
||||||
std::size_t N>
|
basic_value<Comment, Table, Array> parse(const char* fname)
|
||||||
basic_value<Comment, Table, Array> parse(const char (&fname)[N])
|
|
||||||
{
|
{
|
||||||
return parse<Comment, Table, Array>(std::string(fname));
|
return parse<Comment, Table, Array>(std::string(fname));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user