stotko / stdgpu

stdgpu: Efficient STL-like Data Structures on the GPU
https://stotko.github.io/stdgpu/
Apache License 2.0
1.15k stars 81 forks source link

Unordered_set with structure #374

Closed yofufufufu closed 1 year ago

yofufufufu commented 1 year ago

Hello, I'm new to this library. I wonder what should I do if I want to use something like stdgpu::unordered_set<thrust::pair<int, int>> or stdgpu::unordered_set<myStruct> ? Because when I try to use stdgpu::unordered_set<thrust::pair<int, int>>::createDeviceObject(n), the error occurred:

/usr/local/include/c++/9.5.0/type_traits(2378): error: class "std::enable_if<false, thrust::pair<int, int>>" has no member "type"
          detected during:
            instantiation of type "std::enable_if_t<false, thrust::pair<int, int>>" 
stotko commented 1 year ago

stdgpu::unordered_set has similar requirements than std::unordered_set. In particular, this means that stdgpu::hash must be specialized for the desired type and that stdgpu::equal must be able to use the type's operator==() function. For your two examples, this means:

yofufufufu commented 1 year ago

Thanks for your reply! Now I can use stdgpu::unordered_set<thrust::pair<int, int>> with custom hash function.

stotko commented 1 year ago

Closing this issue as the issue has been resolved and further improvements to the less informative error message can be done in the future.