From 06c2ca14bf8ce4a0ae8274154144ffa94001dde5 Mon Sep 17 00:00:00 2001 From: Jeff Trull Date: Thu, 24 Sep 2020 20:58:15 -0700 Subject: [PATCH] Clarify loop logic to satisfy a Clang warning Clang warns that a for loop in a sample increments an iterator in both the header and the body. This seems to be done on purpose to skip whitespace. I used std::advance in the header instead, for clarity. Also cleaned up an unused type in the same file while I was there. --- .../preprocess_pragma_output/preprocess_pragma_output.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/samples/preprocess_pragma_output/preprocess_pragma_output.hpp b/samples/preprocess_pragma_output/preprocess_pragma_output.hpp index 9c2415b..71d2e58 100644 --- a/samples/preprocess_pragma_output/preprocess_pragma_output.hpp +++ b/samples/preprocess_pragma_output/preprocess_pragma_output.hpp @@ -115,7 +115,6 @@ public: typename Context::token_type const& option, Container const& values, typename Context::token_type const& act_token) { - typedef typename Context::token_type token_type; typedef typename Context::iterator_type iterator_type; if (option.get_value() == "pp") { @@ -140,10 +139,10 @@ public: Container pragma; iterator_type end = ctx.end(); for (iterator_type it = ctx.begin(s.begin(), s.end()); - it != end && token_id(*it) != T_EOF; ++it) + it != end && token_id(*it) != T_EOF; + std::advance(it, 2)) // skip over whitespace { pragma.push_back(*it); - it++; } // prepend the newly generated token sequence to the 'pending'