Skip to content

Commit

Permalink
Add @nogc to RebindableCommon methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Dicebot committed Aug 28, 2014
1 parent 4924d9a commit 3b62411
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions std/typecons.d
Expand Up @@ -1061,35 +1061,37 @@ private mixin template RebindableCommon(T, U, alias This)
U stripped;
}

void opAssign(T another) @trusted pure nothrow
@trusted pure nothrow @nogc
{
stripped = cast(U) another;
}

void opAssign(typeof(this) another) @trusted pure nothrow
{
stripped = another.stripped;
}
void opAssign(T another)
{
stripped = cast(U) another;
}

static if (is(T == const U) && is(T == const shared U))
{
// safely assign immutable to const / const shared
void opAssign(This!(immutable U) another) @trusted pure nothrow
void opAssign(typeof(this) another)
{
stripped = another.stripped;
}
}

this(T initializer) @safe pure nothrow
{
opAssign(initializer);
}
static if (is(T == const U) && is(T == const shared U))
{
// safely assign immutable to const / const shared
void opAssign(This!(immutable U) another)
{
stripped = another.stripped;
}
}

@property ref inout(T) get() @trusted inout pure nothrow
{
return original;
}
this(T initializer)
{
opAssign(initializer);
}

@property ref inout(T) get() inout
{
return original;
}
}

alias get this;
}
Expand Down

0 comments on commit 3b62411

Please sign in to comment.