What is the "is" in D?

Inside the std.traits module std.traits I can find a line similar to:

 assert(is(Unqual!(int) == int)); 

I know that Unqual removes modifiers of any type, such as immutable ones, but what does "eat" do? How is it different from the if statement and when should it be used?

+6
source share
2 answers

is(Unqual!(int) == int) is an expression, not an expression. The selected row does not exist in std.traits .

I assume you mean the following line:

 static assert(is(Unqual!int == int)); 

See the documentation for IsExpression .

+8
source

is is an expression that allows, for example, to check whether types are equal if 1 type is a subtype of another or if T class / enum / struct, etc.

The code you checked checks to see if the specified type is of the specified type.

For more information, see the D Language Documentation about IsExpression .

+5
source

All Articles