Skip to content

Commit

Permalink
Merge pull request dlang#867 from jmdavis/rebindable
Browse files Browse the repository at this point in the history
Small tweak to Rebindable
  • Loading branch information
jmdavis committed Oct 14, 2012
2 parents 350d960 + 3bd05ba commit e2a76ce
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -869,15 +869,15 @@ break the soundness of D's type system and does not incur any of the
risks usually associated with $(D cast).
*/
template Rebindable(T) if (is(T == class) || is(T == interface) || isArray!(T))
template Rebindable(T) if (is(T == class) || is(T == interface) || isArray!T)
{
static if (!is(T X == const(U), U) && !is(T X == immutable(U), U))
static if (!is(T X == const U, U) && !is(T X == immutable U, U))
{
alias T Rebindable;
}
else static if (isArray!(T))
else static if (isArray!T)
{
alias const(ElementType!(T))[] Rebindable;
alias const(ElementType!T)[] Rebindable;
}
else
{
Expand Down Expand Up @@ -910,11 +910,7 @@ template Rebindable(T) if (is(T == class) || is(T == interface) || isArray!(T))
opAssign(initializer);
}

@property ref T get() pure nothrow
{
return original;
}
@property ref const(T) get() const pure nothrow
@property ref inout(T) get() inout pure nothrow
{
return original;
}
Expand All @@ -928,8 +924,8 @@ template Rebindable(T) if (is(T == class) || is(T == interface) || isArray!(T))
Convenience function for creating a $(D Rebindable) using automatic type
inference.
*/
Rebindable!(T) rebindable(T)(T obj)
if (is(T == class) || is(T == interface) || isArray!(T))
Rebindable!T rebindable(T)(T obj)
if (is(T == class) || is(T == interface) || isArray!T)
{
typeof(return) ret;
ret = obj;
Expand All @@ -941,7 +937,7 @@ This function simply returns the $(D Rebindable) object passed in. It's useful
in generic programming cases when a given object may be either a regular
$(D class) or a $(D Rebindable).
*/
Rebindable!(T) rebindable(T)(Rebindable!(T) obj)
Rebindable!T rebindable(T)(Rebindable!T obj)
{
return obj;
}
Expand Down

0 comments on commit e2a76ce

Please sign in to comment.