'is(T==return)' How does is expression with return keyword as TypeSpecialization
Steven Schveighoffer
schveiguy at yahoo.com
Thu Jul 5 12:49:16 UTC 2018
On 7/5/18 6:32 AM, Timoses wrote:
> int fun(T)(T i)
> {
> static assert(is(typeof(return) == T)); //true
This is the type of the return value for the function you are in.
> pragma(msg, is(T == return)); // false
This is not a valid is expression, which is why it's false. IMO, I think
this should be an error.
Only is(T == struct), is(T == class), etc. works.
> static if (is(T ReturnType == return))
As you have surmised, if T is a function, function pointer, or delegate,
then it evaluates to true, and ReturnType is set to the return type of
that function. Note, it has nothing to do with the function you are in,
unlike typeof(return).
-Steve
More information about the Digitalmars-d-learn
mailing list