CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HostProduct.h
Go to the documentation of this file.
1 #ifndef CUDADataFormatsCommonHostProduct_H
2 #define CUDADataFormatsCommonHostProduct_H
3 
5 
6 // a heterogeneous unique pointer...
7 template <typename T>
8 class HostProduct {
9 public:
10  HostProduct() = default; // make root happy
11  ~HostProduct() = default;
12  HostProduct(HostProduct&&) = default;
13  HostProduct& operator=(HostProduct&&) = default;
14 
16  explicit HostProduct(std::unique_ptr<T>&& p) : std_ptr(std::move(p)) {}
17 
18  auto const* get() const { return hm_ptr ? hm_ptr.get() : std_ptr.get(); }
19 
20  auto const& operator*() const { return *get(); }
21 
22  auto const* operator->() const { return get(); }
23 
24 private:
26  std::unique_ptr<T> std_ptr;
27 };
28 
29 #endif
~HostProduct()=default
HostProduct(cms::cuda::host::unique_ptr< T > &&p)
Definition: HostProduct.h:15
cms::cuda::host::unique_ptr< T > hm_ptr
Definition: HostProduct.h:25
std::unique_ptr< T > std_ptr
Definition: HostProduct.h:26
HostProduct()=default
HostProduct & operator=(HostProduct &&)=default
def move
Definition: eostools.py:511
auto const & operator*() const
Definition: HostProduct.h:20
auto const * operator->() const
Definition: HostProduct.h:22
HostProduct(std::unique_ptr< T > &&p)
Definition: HostProduct.h:16
std::unique_ptr< T, impl::HostDeleter > unique_ptr