[GiNaC-list] type casting
Marko Riedel
riedelmo at mathematik.uni-stuttgart.de
Fri Feb 10 00:34:00 CET 2023
Hi all,
I have a set of custom objects that is declared like this:
struct cindsym_is_less {
bool operator() (const cindsymbol &lh,
const cindsymbol &rh) const
{ return lh.compare(rh) < 0; }
};
typedef std::set<cindsymbol, cindsym_is_less> cindsymset;
Now I want to collect all custom objects that appear in an expression
tree into this kind of set. I tried this:
void indets_recurse(ex src, cindsymset & coll)
{
if(is_a<add>(src) || is_a<mul>(src) || is_a<power>(src)){
for(size_t idx = 0; idx < src.nops(); idx++)
indets_recurse(src.op(idx), coll);
return;
}
if(is_a<cindsymbol>(src)){
coll.insert(src);
}
}
However this will produce the error "no matching function call" because
src is an expression and not a cindsymbol. I know that I have my kind of
symbol because is_a<cindsymbol> returned true. How can I get at the
symbol wrapped in the expression?
Best regards,
Marko
More information about the GiNaC-list
mailing list