On Monday, 9 September 2013 at 17:07:59 UTC, Gyron wrote:
Hey there, I've experimented a little with UFCS today and ran into a problem.

My first question, which is kinda off-topic:
Why does D use the int type if you give it a number started with 0x(hex), shouldn't it use uint for that ?

It is not a bug, but a feature - see Decimal Literal Types table at http://dlang.org/lex.html

Here comes the real question:
I've extended the int by one function, which is the following (just to represent the problem):
public static T read(T)(int address)
{
        return cast(T)1;
}

It works perfectly if the function stands alone (is global), but it doesn't work if I put it into a class (because I want it to be a bit more organized) like that:
class CMemory
{
        public static T read(T)(int address)
        {
                return cast(T)1;
        }
}

I'm not able to write something like:
0x1212.CMemory.read!bool();


So the question is, how can I make it to be able to be used like this:
0x1212.read!bool();

but still organized within the class ?

class CMemory
{
        public static T read(T)(int address)
        {
                return cast(T)1;
        }
}

alias CMemory.read!int CMread;

void main()
{
         0.CMread();
}

You can also use alias CMemory.read CMread; plus 0.CMread!int();

Reply via email to