rebindable

Convenience function for creating a Rebindable using automatic type inference.

  1. Rebindable!T rebindable(T obj)
    rebindable
    (
    T
    )
    (
    T obj
    )
    if (
    is(T == class) ||
    is(T == interface)
    ||
    ||
    )
  2. Rebindable!T rebindable(Rebindable!T obj)

Parameters

obj T

A reference to an object, interface, associative array, or an array slice to initialize the Rebindable with.

Return Value

Type: Rebindable!T

A newly constructed Rebindable initialized with the given reference.

Examples

1 class C
2 {
3     int payload;
4     this(int p) { payload = p; }
5 }
6 const c = new C(1);
7 
8 auto c2 = c.rebindable;
9 assert(c2.payload == 1);
10 // passing Rebindable to rebindable
11 c2 = c2.rebindable;
12 
13 c2 = new C(2);
14 assert(c2.payload == 2);
15 
16 const c3 = c2.get;
17 assert(c3.payload == 2);

Meta

Suggestion Box / Bug Report