From ee3424ad51a8d2b7eff0bbdb06ac69e35cedf2d6 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Thu, 27 Dec 2018 16:26:23 +0900 Subject: [PATCH 1/2] add an extra parameter `hints` to format_error --- toml/value.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/toml/value.hpp b/toml/value.hpp index 5d7898c..8b20a0b 100644 --- a/toml/value.hpp +++ b/toml/value.hpp @@ -801,17 +801,20 @@ inline bool operator>=(const toml::value& lhs, const toml::value& rhs) } inline std::string format_error(const std::string& err_msg, - const toml::value& v, const std::string& comment) + const toml::value& v, const std::string& comment, + std::vector hints = {}) { - return detail::format_underline(err_msg, detail::get_region(v), comment); + return detail::format_underline(err_msg, detail::get_region(v), comment, hints); } inline std::string format_error(const std::string& err_msg, const toml::value& v1, const std::string& comment1, - const toml::value& v2, const std::string& comment2) + const toml::value& v2, const std::string& comment2, + std::vector hints = {}) { return detail::format_underline(err_msg, detail::get_region(v1), comment1, - detail::get_region(v2), comment2); + detail::get_region(v2), comment2, + hints); } }// toml From aa67069387e573c83cfbb0b4c2bdbf54949387e7 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Thu, 27 Dec 2018 16:32:20 +0900 Subject: [PATCH 2/2] move hints to the internal function --- toml/value.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toml/value.hpp b/toml/value.hpp index 8b20a0b..9088df8 100644 --- a/toml/value.hpp +++ b/toml/value.hpp @@ -804,7 +804,8 @@ inline std::string format_error(const std::string& err_msg, const toml::value& v, const std::string& comment, std::vector hints = {}) { - return detail::format_underline(err_msg, detail::get_region(v), comment, hints); + return detail::format_underline(err_msg, detail::get_region(v), comment, + std::move(hints)); } inline std::string format_error(const std::string& err_msg, @@ -814,7 +815,7 @@ inline std::string format_error(const std::string& err_msg, { return detail::format_underline(err_msg, detail::get_region(v1), comment1, detail::get_region(v2), comment2, - hints); + std::move(hints)); } }// toml