[GiNaC-list] type casting

Marko Riedel riedelmo at mathematik.uni-stuttgart.de
Fri Feb 10 01:37:29 CET 2023


Never mind, I am still learning. I found the ex_to converter and now 
everything is working.

Marko

Am 10.02.23 um 00:34 schrieb Marko Riedel:
> 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
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> https://www.ginac.de/mailman/listinfo/ginac-list


More information about the GiNaC-list mailing list