lion03 / thrust

Automatically exported from code.google.com/p/thrust
Apache License 2.0
0 stars 0 forks source link

thrust implementations need to call unqualified swap #353

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
take a look at 17.6.3.2 "Swappable requirements"

Basically, we just need to use unqualified swap in our implementation, and 
provide overloads in thrust:: for things we want to catch.  ADL lookup follows 
different rules than fully-qualified overloads (i.e., order doesn't matter).  
The one change I made was to make thrust::detail::swap_pair_elements use 
unqualified swap.  This makes the tests pass.  There are just a few other 
places we use fully-qualified thrust::swap, so we should probably standardize 
on unqualified swap.  Technically, sort is supposed to rely on swap to work.

If a user has #included thrust headers (in any order), he will get the expected 
behavior whether he uses unqualified swap or thrust::swap on things we've 
overloaded swap for.  By the time he uses thrust::swap, he has all the 
overloads in existence.

What could break is if a user's type has __host__ swap defined for it.  Then, 
nvcc will balk at our use of unqualified swap because it will select a non 
host/device function.  This might be ok, because it's unlikely that 
thrust::swap would do the right thing in this case.

seems like the standard treats swap specially in this regard.  there doesn't 
seem to be any other similar points of customization.

Original issue reported on code.google.com by jaredhoberock on 30 Jul 2011 at 12:33

GoogleCodeExporter commented 8 years ago
Probably ought to add a unit test for this to make sure a user's swap gets 
called by e.g. swap_ranges

Original comment by jaredhoberock on 1 Aug 2011 at 6:26

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 3b9834ddc667.

Original comment by jaredhoberock on 4 Aug 2011 at 1:39