Hi folks,

I've got this very simple program, for which I keep getting compiler errors at 
the 'cas' function call.

import
        std.stdio,
        core.atomic;

class Int
{
public:
        this(int v) {
                this._v = v;
        }

private:
        int _v;
}


void main()
{
        shared(Int) a = new shared(Int)(10);
        shared(Int) b = new shared(Int)(20);
        shared(Int*) p = &a;

        if ( cas(p, a, b) ) {
                writeln("Swap OK");
        }
}

The errors are:

Error: template core.atomic.cas(T,V1,V2) if (__traits(compiles,mixin("*here = 
writeThis"))) does not match any
function template declaration

Error: template core.atomic.cas(T,V1,V2) if (__traits(compiles,mixin("*here = 
writeThis"))) cannot deduce template
function from argument types !()(shared(Int*),shared(Int),shared(Int))

Is it not possible to compare and swap object references in the cas function 
call?
Would someone kindly tell me as to what I am doing wrong?

Thanks.
- Adrian.

Reply via email to