mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-26 06:10:06 +00:00
Merge pull request #189 from muggenhor/fix/avoid-fname-copy
fix: don't force a copy of std::string fname when moving is an option
This commit is contained in:
commit
6d9e533cf1
@ -2317,7 +2317,7 @@ template<typename Comment = TOML11_DEFAULT_COMMENT_STRATEGY,
|
||||
template<typename ...> class Table = std::unordered_map,
|
||||
template<typename ...> class Array = std::vector>
|
||||
basic_value<Comment, Table, Array>
|
||||
parse(std::istream& is, const std::string& fname = "unknown file")
|
||||
parse(std::istream& is, std::string fname = "unknown file")
|
||||
{
|
||||
using value_type = basic_value<Comment, Table, Array>;
|
||||
|
||||
@ -2372,14 +2372,14 @@ parse(std::istream& is, const std::string& fname = "unknown file")
|
||||
template<typename Comment = TOML11_DEFAULT_COMMENT_STRATEGY,
|
||||
template<typename ...> class Table = std::unordered_map,
|
||||
template<typename ...> class Array = std::vector>
|
||||
basic_value<Comment, Table, Array> parse(const std::string& fname)
|
||||
basic_value<Comment, Table, Array> parse(std::string fname)
|
||||
{
|
||||
std::ifstream ifs(fname.c_str(), std::ios_base::binary);
|
||||
if(!ifs.good())
|
||||
{
|
||||
throw std::runtime_error("toml::parse: file open error -> " + fname);
|
||||
}
|
||||
return parse<Comment, Table, Array>(ifs, fname);
|
||||
return parse<Comment, Table, Array>(ifs, std::move(fname));
|
||||
}
|
||||
|
||||
#ifdef TOML11_HAS_STD_FILESYSTEM
|
||||
|
Loading…
Reference in New Issue
Block a user