Sudoku Py / C++11 / D?

Ali Çehreli acehreli at yahoo.com
Mon Aug 20 17:03:42 PDT 2012


On 08/19/2012 02:39 AM, maarten van damme wrote:

 > -is it normal that const ref is slower then ref?

Not normal but it can be arranged. :p

import std.stdio;
import core.thread;

struct S
{
     void foo()
     {}

     void foo() const
     {
         Thread.sleep(dur!("seconds")(3));
     }
}

void takes_ref(ref S s)
{
     s.foo();
}

void takes_const_ref(const ref S s)
{
     s.foo();
}

void main()
{
     auto s = S();
     takes_ref(s);
     takes_const_ref(s);
}

Ali



More information about the Digitalmars-d-learn mailing list