From 68e8a3165950c43fb0d3485015a41a761a5055bd Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Mon, 27 Jul 2020 23:00:40 +0900 Subject: [PATCH] refactor: remove needless addressof() call --- toml/literal.hpp | 3 +-- toml/parser.hpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/toml/literal.hpp b/toml/literal.hpp index 65a5511..5292b3d 100644 --- a/toml/literal.hpp +++ b/toml/literal.hpp @@ -76,8 +76,7 @@ inline ::toml::value operator"" _toml(const char* str, std::size_t len) } else // none of them. { - throw ::toml::syntax_error(data.unwrap_err(), - source_location(std::addressof(loc))); + throw ::toml::syntax_error(data.unwrap_err(), source_location(loc)); } } diff --git a/toml/parser.hpp b/toml/parser.hpp index 6d3b73c..7ef196a 100644 --- a/toml/parser.hpp +++ b/toml/parser.hpp @@ -39,7 +39,7 @@ parse_boolean(location& loc) throw internal_error(format_underline( "toml::parse_boolean: internal error", {{source_location(reg), "invalid token"}}), - source_location(std::addressof(reg))); + source_location(reg)); } } loc.reset(first); //rollback @@ -66,7 +66,7 @@ parse_binary_integer(location& loc) throw internal_error(format_underline( "toml::parse_integer: internal error", {{source_location(token.unwrap()), "invalid token"}}), - source_location(std::addressof(loc))); + source_location(loc)); } } return ok(std::make_pair(retval, token.unwrap())); @@ -280,7 +280,7 @@ inline std::string read_utf8_codepoint(const region& reg, const location& loc) "toml::read_utf8_codepoint: codepoints in the range " "[0xD800, 0xDFFF] are not valid UTF-8.", {{ source_location(loc), "not a valid UTF-8 codepoint" - }}), source_location(std::addressof(loc))); + }}), source_location(loc)); } assert(codepoint < 0xD800 || 0xDFFF < codepoint); // 1110yyyy 10yxxxxx 10xxxxxx @@ -301,7 +301,7 @@ inline std::string read_utf8_codepoint(const region& reg, const location& loc) throw syntax_error(format_underline("toml::read_utf8_codepoint:" " input codepoint is too large.", {{source_location(loc), "should be in [0x00..0x10FFFF]"}}), - source_location(std::addressof(loc))); + source_location(loc)); } return character; } @@ -1007,7 +1007,7 @@ parse_array(location& loc) "value having invalid format appeared in an array", { {source_location(array_start_loc), "array starts here"}, {source_location(loc), "it is not a valid value."} - }), source_location(std::addressof(loc))); + }), source_location(loc)); } using lex_array_separator = sequence, character<','>>; @@ -1030,7 +1030,7 @@ parse_array(location& loc) " missing array separator `,` after a value", { {source_location(array_start_loc), "array starts here"}, {source_location(loc), "should be `,`"} - }), source_location(std::addressof(loc))); + }), source_location(loc)); } } } @@ -1038,7 +1038,7 @@ parse_array(location& loc) throw syntax_error(format_underline("toml::parse_array: " "array did not closed by `]`", {{source_location(loc), "should be closed"}}), - source_location(std::addressof(loc))); + source_location(loc)); } template @@ -1478,7 +1478,7 @@ parse_inline_table(location& loc) { throw internal_error("toml::parse_inline_table: " "failed to insert value into table: " + inserted.unwrap_err(), - source_location(std::addressof(loc))); + source_location(loc)); } using lex_table_separator = sequence, character<','>>; @@ -2067,7 +2067,7 @@ parse(std::istream& is, const std::string& fname = "unknown file") const auto data = detail::parse_toml_file(loc); if(!data) { - throw syntax_error(data.unwrap_err(), source_location(std::addressof(loc))); + throw syntax_error(data.unwrap_err(), source_location(loc)); } return data.unwrap(); }