[GiNaC-devel] Best way to iterate through an expression

Jan Rheinländer jrheinlaender at gmx.de
Mon May 8 20:06:14 CEST 2017


Hi,

my code has a lot of statements of this kind:

if (is_a<mul>(some_ex)) {
    for (const auto& m : some_ex) {
      // Do something with m
    }
  } else  {
    // Do something with some_ex
  }

Is there a more elegant way of iterating through an expression that
avoids having to write the "Do something" part twice?

Thanks,

Jan



More information about the GiNaC-devel mailing list