constCall

Allows to call a non const method as if it was const.

constCall
(
string func
Aggr
A...
)
(
Aggr aggr
,
auto ref A a
)
if (
__traits(hasMember, Aggr, func)
)

Parameters

func

The member function to call.

aggr
Type: Aggr

The aggregate that contains $(D_Param func).

a
Type: A

The parameters passed when calling $(D_Param func).

Return Value

Type: auto

Depends on $(D_Param func) return type.

Examples

1 static struct Foo
2 {
3     int a;
4 
5     void nonConstFunc()  { a = 1;}
6     void constFunc() const {constCall!"nonConstFunc"(this);}
7 }
8 Foo foo;
9 foo.constFunc();

Meta