Re: Help, what is the code mean?

2020-04-27 Thread lilijreey via Digitalmars-d-learn
The stdlib uses that pattern from time to time to indicate an unsafe block in an otherwise safe function. Specifically it is a little trusted inline function being immediately called. It is something that should be avoided whenever you can. Thanks your help. where is unsafe in above code?

Help, what is the code mean?

2020-04-27 Thread lilijreey via Digitalmars-d-learn
Hi: In dlang core.thread.osthread has below code, the 654 line code i can understand why write () first, and {m_fn = fn;}() do what? ``` this( void function() fn, size_t sz = 0 ) @safe pure nothrow @nogc 647 in 648 { 649 assert( fn ); 650 } 651 do

what is the different bettwen typeid and .classinfo?

2020-03-30 Thread lilijreey via Digitalmars-d-learn
Hi: I write code like this ```D class Base { int base; } class CC :Base { int cc; } auto cc = new CC; //I want check cc object type is CC if (typeid(cc) == typeid(CC)) // ok == if (cc.classinfo == AstAssignNode) //error if (cc.classinfo == AstAssignNode.classinfo) // ok == ```