Permalink
Browse files

Forward sort - Use standard swap for ranges with ref-able arguments

  • Loading branch information...
1 parent aa3159d commit 427726e617289debdd6e493ddc6659ef632492ee @Xinok committed Jul 28, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 forwardsort.d
View
@@ -234,9 +234,13 @@ template ForwardSortImpl(alias pred, R)
/// Swap front elements of two forward ranges
void swapFront(R a, R b)
{
- auto o = a.front;
- a.front = b.front;
- b.front = o;
+ static if(hasSwappableElements!R) swap(a.front, b.front);
+ else
+ {
+ auto o = a.front;
+ a.front = b.front;
+ b.front = o;
+ }
}
}

0 comments on commit 427726e

Please sign in to comment.