Re: Fastest way to check if the bottom-class of a class reference is any of a set of classes

2019-12-17 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 16 December 2019 at 18:01:06 UTC, Steven Schveighoffer wrote: I'd compare the typeid directly: auto tid = typeid(object); return(tid is typeid(X) || tid is typeid(Y) || tid is typeid(Z) || ...) If you are doing a cast(const(X))object, what you are doing is each time traversing

Re: Fastest way to check if the bottom-class of a class reference is any of a set of classes

2019-12-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/16/19 9:38 AM, Per Nordlöw wrote: What is the fastest way to check whether a class reference is an instance of a bottom equal to any in a set of classes? My current try is something like class C {} class X : C {} class Y : C {} class Z : C {} bool pred(scope const Object object) {

Re: Fastest way to check if the bottom-class of a class reference is any of a set of classes

2019-12-16 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 16, 2019 at 02:38:59PM +, Per Nordlöw via Digitalmars-d-learn wrote: > What is the fastest way to check whether a class reference is an instance of > a > bottom equal to any in a set of classes? My current try is something like > > class C {} > > class X : C {} > class Y : C {}

Fastest way to check if the bottom-class of a class reference is any of a set of classes

2019-12-16 Thread Per Nordlöw via Digitalmars-d-learn
What is the fastest way to check whether a class reference is an instance of a bottom equal to any in a set of classes? My current try is something like class C {} class X : C {} class Y : C {} class Z : C {} ... bool pred(scope const Object object) { return (cast(const(X))object ||