From 4b719f080684bee386bbf89a71ddc0553307cc1b Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Mon, 27 Jul 2020 23:15:14 +0900 Subject: [PATCH] refactor: use location() instead of get_region --- toml/get.hpp | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/toml/get.hpp b/toml/get.hpp index cd0b034..3be82bf 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -189,8 +189,7 @@ get(const basic_value& v) { throw type_error(detail::format_underline("toml::value: " "bad_cast to std::chrono::system_clock::time_point", { - {source_location(detail::get_region(v)), - concat_to_string("the actual type is ", v.type())} + {v.location(), concat_to_string("the actual type is ", v.type())} }), v.location()); } } @@ -336,7 +335,7 @@ get(const basic_value& v) throw std::out_of_range(detail::format_underline(concat_to_string( "toml::get: specified container size is ", container.size(), " but there are ", ar.size(), " elements in toml array."), { - {source_location(detail::get_region(v)), "here"} + {v.location(), "here"} })); } std::transform(ar.cbegin(), ar.cend(), container.begin(), @@ -360,9 +359,7 @@ get(const basic_value& v) { throw std::out_of_range(detail::format_underline(concat_to_string( "toml::get: specified std::pair but there are ", ar.size(), - " elements in toml array."), { - {source_location(detail::get_region(v)), "here"} - })); + " elements in toml array."), {{v.location(), "here"}})); } return std::make_pair(::toml::get(ar.at(0)), ::toml::get(ar.at(1))); @@ -392,9 +389,7 @@ get(const basic_value& v) throw std::out_of_range(detail::format_underline(concat_to_string( "toml::get: specified std::tuple with ", std::tuple_size::value, " elements, but there are ", ar.size(), - " elements in toml array."), { - {source_location(detail::get_region(v)), "here"} - })); + " elements in toml array."), {{v.location(), "here"}})); } return detail::get_tuple_impl(ar, detail::make_index_sequence::value>{}); @@ -511,9 +506,7 @@ find(const basic_value& v, const std::size_t idx) if(ary.size() <= idx) { throw std::out_of_range(detail::format_underline(concat_to_string( - "index ", idx, " is out of range"), { - {source_location(detail::get_region(v)), "in this array"} - })); + "index ", idx, " is out of range"), {{v.location(), "in this array"}})); } return ary.at(idx); } @@ -525,9 +518,7 @@ basic_value& find(basic_value& v, const std::size_t idx) if(ary.size() <= idx) { throw std::out_of_range(detail::format_underline(concat_to_string( - "index ", idx, " is out of range"), { - {source_location(detail::get_region(v)), "in this array"} - })); + "index ", idx, " is out of range"), {{v.location(), "in this array"}})); } return ary.at(idx); } @@ -539,9 +530,7 @@ basic_value find(basic_value&& v, const std::size_t idx) if(ary.size() <= idx) { throw std::out_of_range(detail::format_underline(concat_to_string( - "index ", idx, " is out of range"), { - {source_location(detail::get_region(v)), "in this array"} - })); + "index ", idx, " is out of range"), {{v.location(), "in this array"}})); } return basic_value(std::move(ary.at(idx))); } @@ -599,9 +588,7 @@ find(const basic_value& v, const std::size_t idx) if(ary.size() <= idx) { throw std::out_of_range(detail::format_underline(concat_to_string( - "index ", idx, " is out of range"), { - {source_location(detail::get_region(v)), "in this array"} - })); + "index ", idx, " is out of range"), {{v.location(), "in this array"}})); } return ::toml::get(ary.at(idx)); } @@ -614,9 +601,7 @@ find(basic_value& v, const std::size_t idx) if(ary.size() <= idx) { throw std::out_of_range(detail::format_underline(concat_to_string( - "index ", idx, " is out of range"), { - {source_location(detail::get_region(v)), "in this array"} - })); + "index ", idx, " is out of range"), {{v.location(), "in this array"}})); } return ::toml::get(ary.at(idx)); } @@ -629,9 +614,7 @@ find(basic_value&& v, const std::size_t idx) if(ary.size() <= idx) { throw std::out_of_range(detail::format_underline(concat_to_string( - "index ", idx, " is out of range"), { - {source_location(detail::get_region(v)), "in this array"} - })); + "index ", idx, " is out of range"), {{v.location(), "in this array"}})); } return ::toml::get(std::move(ary.at(idx))); }