antlr4-cpp icon indicating copy to clipboard operation
antlr4-cpp copied to clipboard

About antlrcpp::Any derived.

Open RonxBulld opened this issue 4 years ago • 1 comments

Hi, There are the following codes:

class A {};
class B : public A {};
B *b = new B;
antlrcpp::Any any = b;
bool is = any.is<A*>();

Variable ìs' always `false'. How do I solve this type of derivation problem?

RonxBulld avatar Jan 20 '20 13:01 RonxBulld

Maybe your can using another solution:

class A {};
class B : public A {};
A *b = (A*)new B;
antlrcpp::Any any = b;
bool is = any.is<A*>();//true

ScSofts avatar Dec 19 '21 15:12 ScSofts