__traits(compiles , mixin ... )

SrMordred patric.dexheimer at gmail.com
Wed Oct 25 19:30:10 UTC 2017


On Wednesday, 25 October 2017 at 19:25:01 UTC, Adam D. Ruppe 
wrote:
> On Wednesday, 25 October 2017 at 19:12:02 UTC, SrMordred wrote:
>> Maybe i´m tired already, but whats wrong here:
>>
>> pragma(msg, __traits( compiles, mixin("int x") ) );
>
> You are missing a ;
>
> The mixin must compile as a full thing in context. Variable 
> declarations need the ; to be complete.

it returns false anyway.

void F(){
   writeln("inside");
}

struct T{}

void main()
{
         pragma(msg, __traits( compiles, mixin("int x;") ) 
);//false

	pragma(msg, __traits( compiles, mixin("F();") ) );//false
	pragma(msg, __traits( compiles, mixin("F()") ) );//true
	mixin( "F();" ); //compiles
	
	pragma(msg, __traits( compiles, mixin("T();") ) ); //false
	pragma(msg, __traits( compiles, mixin("T()") ) ); // true
	mixin( "T();" ); // Error: `structliteral` has no effect in 
expression `T()`
}


More information about the Digitalmars-d-learn mailing list