I want a function with parameter o!(const(Form)) to accept both o!(Form) and o!(immutable(Form))

Is there a way to do it?




import std.stdio;
import std.traits;


class Form
{
        int number = 10;
}

struct o(T)
{
        T data;

        this(T data)
        {
                this.data = data;
        }

        o!(const(Unqual!(T))) constify() const
        {
                return o!(const(Unqual!(T)))(data);
        }

        alias constify this;
}


void hello(o!(const(Form)) frm)
{
  writeln(frm.data.number);
  writeln(typeof(frm.data).stringof);
}

void main()
{
        writeln("This application works nicely");
        auto frm = o!(Form) (new Form());
//      auto ifrm = o!(immutable(Form)) (new immutable Form());

        hello(frm);
//      hello(ifrm);
}

Reply via email to