Is this possible in D?

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 19 02:17:46 PST 2015


Most practical approach I am currently aware of is wrapping 
actual implementation (in most restrictive version):

class Test {

private static void foo_() {}

version (Static)
{
      static void foo() { foo_(); }
}
else
{
      void foo() { foo_(); }
}

private void bar_() shared
{
}

version (Shared)
{
     void bar() shared { bar_(); }
}
else
{
     void bar() { (cast(shared Test)this).bar_(); }
}

}

But this relies on very careful code review because of casual 
casts for certain attributes (static and public/private are easy 
in that regard)


More information about the Digitalmars-d-learn mailing list