Error: type XXX is not an expression

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Sep 1 21:48:23 PDT 2013


On Mon, Sep 02, 2013 at 06:21:18AM +0200, Era Scarecrow wrote:
>   k here's the condensed test file. Seems related to an 'alias
> this', in theory the HandleFlags bit/flag handling you should be
> able to say 'state.def' and it would be the same as
> 'FlagStates.def' without actually having to name it.
> 
> [code]
> 
> import std.traits;
> 
> ///
> struct HandleFlags(E, I)
> if (is(E == enum) && isIntegral!(I) && isFloatingPoint!(I) ==
> false) {
>    I state;	///Holds state.
>    alias E Enum;
>    alias Enum this;    //seems to be root cause of the problem...

You can't alias a type to this. You need to instantiate it first, then
alias the instance to this (because 'this' is an object, not a type).
For example:

	struct S {}
	struct T {
		//alias S this;  // NG: S is a type
		S s;
		alias s this;	// OK: s is an instance of S
	}


T

-- 
Three out of two people have difficulties with fractions. -- Dirk Eddelbuettel


More information about the Digitalmars-d-learn mailing list