From e7d5c5332d543f0fcc2218979ff7fc41952449b6 Mon Sep 17 00:00:00 2001 From: Dodzey Date: Sun, 27 Oct 2019 17:42:53 +0000 Subject: [PATCH] Static cast to avoid VS140 C4244 warning (#119) --- include/inja/parser.hpp | 12 ++++++++---- single_include/inja/inja.hpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/inja/parser.hpp b/include/inja/parser.hpp index 461f693..bbddd30 100644 --- a/include/inja/parser.hpp +++ b/include/inja/parser.hpp @@ -280,7 +280,7 @@ class Parser { if (!parse_expression(tmpl)) return false; // start a new if block on if stack - m_if_stack.emplace_back(tmpl.bytecodes.size()); + m_if_stack.emplace_back(static_cast(tmpl.bytecodes.size())); // conditional jump; destination will be filled in by else or endif tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump); @@ -530,10 +530,14 @@ class Parser { const ParserStatic& m_static; struct IfData { - unsigned int prev_cond_jump; - std::vector uncond_jumps; + using jump_t = unsigned int; + jump_t prev_cond_jump; + std::vector uncond_jumps; - explicit IfData(unsigned int condJump): prev_cond_jump(condJump) {} + explicit IfData(jump_t condJump) + : prev_cond_jump(condJump) + { + } }; std::vector m_if_stack; diff --git a/single_include/inja/inja.hpp b/single_include/inja/inja.hpp index cd77c2c..beb284e 100644 --- a/single_include/inja/inja.hpp +++ b/single_include/inja/inja.hpp @@ -2362,7 +2362,7 @@ class Parser { if (!parse_expression(tmpl)) return false; // start a new if block on if stack - m_if_stack.emplace_back(tmpl.bytecodes.size()); + m_if_stack.emplace_back(static_cast(tmpl.bytecodes.size())); // conditional jump; destination will be filled in by else or endif tmpl.bytecodes.emplace_back(Bytecode::Op::ConditionalJump); @@ -2612,10 +2612,14 @@ class Parser { const ParserStatic& m_static; struct IfData { - unsigned int prev_cond_jump; - std::vector uncond_jumps; + using jump_t = unsigned int; + jump_t prev_cond_jump; + std::vector uncond_jumps; - explicit IfData(unsigned int condJump): prev_cond_jump(condJump) {} + explicit IfData(jump_t condJump) + : prev_cond_jump(condJump) + { + } }; std::vector m_if_stack;