Skip to content

Commit

Permalink
Reverse static condition in Rebindable/RefUnqual
Browse files Browse the repository at this point in the history
  • Loading branch information
Dicebot committed Aug 28, 2014
1 parent 3b62411 commit 6ec8c52
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions std/typecons.d
Expand Up @@ -1132,20 +1132,23 @@ risks usually associated with $(D cast).
*/
template Rebindable(T) if (is(T == class) || is(T == interface) || isDynamicArray!T)
{
static if (!is(T == const U, U) && !is(T == immutable U, U))
static if (is(T == const U, U) || is(T == immutable U, U))
{
alias Rebindable = T;
}
else static if (isDynamicArray!T)
{
alias Rebindable = const(ElementEncodingType!T)[];
static if (isDynamicArray!T)
{
alias Rebindable = const(ElementEncodingType!T)[];
}
else
{
struct Rebindable
{
mixin RebindableCommon!(T, U, Rebindable);
}
}
}
else
{
struct Rebindable
{
mixin RebindableCommon!(T, U, Rebindable);
}
alias Rebindable = T;
}
}

Expand Down Expand Up @@ -1262,20 +1265,20 @@ unittest
template UnqualRef(T)
if (is(T == class) || is(T == interface))
{
static if (!is(T == const U, U)
&& !is(T == immutable U, U)
&& !is(T == shared U, U)
&& !is(T == const shared U, U))
{
alias UnqualRef = T;
}
else
static if (is(T == const U, U)
|| is(T == immutable U, U)
|| is(T == shared U, U)
|| is(T == const shared U, U))
{
struct UnqualRef
{
mixin RebindableCommon!(T, U, UnqualRef);
}
}
else
{
alias UnqualRef = T;
}
}

///
Expand Down

0 comments on commit 6ec8c52

Please sign in to comment.