Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:49

0001 #ifndef CUDADataFormatsCommonHostProduct_H
0002 #define CUDADataFormatsCommonHostProduct_H
0003 
0004 #include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
0005 
0006 // a heterogeneous unique pointer...
0007 template <typename T>
0008 class HostProduct {
0009 public:
0010   HostProduct() = default;  // make root happy
0011   ~HostProduct() = default;
0012   HostProduct(HostProduct&&) = default;
0013   HostProduct& operator=(HostProduct&&) = default;
0014 
0015   explicit HostProduct(cms::cuda::host::unique_ptr<T>&& p) : hm_ptr(std::move(p)) {}
0016   explicit HostProduct(std::unique_ptr<T>&& p) : std_ptr(std::move(p)) {}
0017 
0018   auto const* get() const { return hm_ptr ? hm_ptr.get() : std_ptr.get(); }
0019 
0020   auto const& operator*() const { return *get(); }
0021 
0022   auto const* operator->() const { return get(); }
0023 
0024 private:
0025   cms::cuda::host::unique_ptr<T> hm_ptr;  //!
0026   std::unique_ptr<T> std_ptr;             //!
0027 };
0028 
0029 #endif