dirkschumacher / armacmp

🚀 Automatically compile linear algebra R code to C++ with Armadillo

Home Page:https://dirkschumacher.github.io/armacmp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

For loop should only create a loop variable if it is used

dirkschumacher opened this issue · comments

x <- 10
for(i in seq_len(10)) {
  x <- x + 1
}

Problem is that then a warning is issued that i is not used but declared.

Maybe always directly convert it to:

auto && __range = range_expression ;
for (auto __begin = begin_expr, __end = end_expr; __begin != __end; ++__begin) {

   range_declaration = *__begin;
   loop_statement

} 

https://en.cppreference.com/w/cpp/language/range-for