From 17a59c0b78e620157c253b0c7643cfa987135f8d Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Mon, 20 Jun 2022 13:06:28 +0300 Subject: [PATCH] fix warnings with VS2019, W4, c++20 (#230) * fix warnings with VS2019, W4, c++20 * update single include Co-authored-by: Berscheid <1885260+pantor@users.noreply.github.com> Co-authored-by: pantor --- include/inja/parser.hpp | 6 +++--- include/inja/renderer.hpp | 4 ++-- single_include/inja/inja.hpp | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/inja/parser.hpp b/include/inja/parser.hpp index 3fbbfcc5..934db7be 100644 --- a/include/inja/parser.hpp +++ b/include/inja/parser.hpp @@ -122,7 +122,7 @@ class Parser { } } - std::string parse_filename(const Token& tok) const { + std::string parse_filename() const { if (tok.kind != Token::Kind::String) { throw_parser_error("expected string, got '" + tok.describe() + "'"); } @@ -512,7 +512,7 @@ class Parser { } else if (tok.text == static_cast("include")) { get_next_token(); - std::string template_name = parse_filename(tok); + std::string template_name = parse_filename(); add_to_template_storage(path, template_name); current_block->nodes.emplace_back(std::make_shared(template_name, tok.text.data() - tmpl.content.c_str())); @@ -521,7 +521,7 @@ class Parser { } else if (tok.text == static_cast("extends")) { get_next_token(); - std::string template_name = parse_filename(tok); + std::string template_name = parse_filename(); add_to_template_storage(path, template_name); current_block->nodes.emplace_back(std::make_shared(template_name, tok.text.data() - tmpl.content.c_str())); diff --git a/include/inja/renderer.hpp b/include/inja/renderer.hpp index bebdb3ee..f988673b 100644 --- a/include/inja/renderer.hpp +++ b/include/inja/renderer.hpp @@ -352,7 +352,7 @@ class Renderer : public NodeVisitor { } break; case Op::Lower: { auto result = get_arguments<1>(node)[0]->get(); - std::transform(result.begin(), result.end(), result.begin(), ::tolower); + std::transform(result.begin(), result.end(), result.begin(), [](char c) { return static_cast(::tolower(c)); }); make_result(std::move(result)); } break; case Op::Max: { @@ -391,7 +391,7 @@ class Renderer : public NodeVisitor { } break; case Op::Upper: { auto result = get_arguments<1>(node)[0]->get(); - std::transform(result.begin(), result.end(), result.begin(), ::toupper); + std::transform(result.begin(), result.end(), result.begin(), [](char c) { return static_cast(::toupper(c)); }); make_result(std::move(result)); } break; case Op::IsBoolean: { diff --git a/single_include/inja/inja.hpp b/single_include/inja/inja.hpp index 2feee8ba..bd167a3c 100644 --- a/single_include/inja/inja.hpp +++ b/single_include/inja/inja.hpp @@ -1536,7 +1536,7 @@ class Parser { } } - std::string parse_filename(const Token& tok) const { + std::string parse_filename() const { if (tok.kind != Token::Kind::String) { throw_parser_error("expected string, got '" + tok.describe() + "'"); } @@ -1926,7 +1926,7 @@ class Parser { } else if (tok.text == static_cast("include")) { get_next_token(); - std::string template_name = parse_filename(tok); + std::string template_name = parse_filename(); add_to_template_storage(path, template_name); current_block->nodes.emplace_back(std::make_shared(template_name, tok.text.data() - tmpl.content.c_str())); @@ -1935,7 +1935,7 @@ class Parser { } else if (tok.text == static_cast("extends")) { get_next_token(); - std::string template_name = parse_filename(tok); + std::string template_name = parse_filename(); add_to_template_storage(path, template_name); current_block->nodes.emplace_back(std::make_shared(template_name, tok.text.data() - tmpl.content.c_str())); @@ -2428,7 +2428,7 @@ class Renderer : public NodeVisitor { } break; case Op::Lower: { auto result = get_arguments<1>(node)[0]->get(); - std::transform(result.begin(), result.end(), result.begin(), ::tolower); + std::transform(result.begin(), result.end(), result.begin(), [](char c) { return static_cast(::tolower(c)); }); make_result(std::move(result)); } break; case Op::Max: { @@ -2467,7 +2467,7 @@ class Renderer : public NodeVisitor { } break; case Op::Upper: { auto result = get_arguments<1>(node)[0]->get(); - std::transform(result.begin(), result.end(), result.begin(), ::toupper); + std::transform(result.begin(), result.end(), result.begin(), [](char c) { return static_cast(::toupper(c)); }); make_result(std::move(result)); } break; case Op::IsBoolean: {