what is the different bettwen typeid and .classinfo?

Pham home at home.com
Mon Mar 30 21:17:07 UTC 2020


On Monday, 30 March 2020 at 18:20:00 UTC, Steven Schveighoffer 
wrote:
> On 3/30/20 1:06 PM, Pham wrote:

>> 
>> Will it be the same if using "is", the reason is for function 
>> that use "nothrow" attribute?
>> if (cc.classinfo is typeid(CC))
>
>
> I don't really understand the question about "nothrow".
>
> -Steve

void main()
{
	static class Foo { int i; }
	
	static bool checkFoo() nothrow
	{
		// error when compile
		//return typeid(Foo) == Foo.classinfo;
		
		// ok when compile
		return typeid(Foo) is Foo.classinfo;
	}
		
	checkFoo();
}





More information about the Digitalmars-d-learn mailing list