Commit 0dff62ab authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added operators for conversion of smart pointers to bool

parent 2c6da83e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -116,6 +116,11 @@ class DevicePointer< Object, Devices::Host > : public SmartPointer
         return *( this->pointer );
      }

      operator bool()
      {
         return this->pointer;
      }

      template< typename Device = Devices::Host >
      __cuda_callable__
      const Object& getData() const
@@ -288,6 +293,11 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
         return *( this->pointer );
      }

      operator bool()
      {
         return this->pointer;
      }

      template< typename Device = Devices::Host >
      __cuda_callable__
      const Object& getData() const
+10 −0
Original line number Diff line number Diff line
@@ -183,6 +183,11 @@ class SharedPointer< Object, Devices::Host, lazy > : public SmartPointer
         return *( this->pointer );
      }

      operator bool()
      {
         return this->pointer;
      }

      template< typename Device = Devices::Host >
      __cuda_callable__
      const Object& getData() const
@@ -433,6 +438,11 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer
         return *( this->pointer );
      }

      operator bool()
      {
         return this->pointer;
      }

      template< typename Device = Devices::Host >
      __cuda_callable__
      const Object& getData() const
+22 −2
Original line number Diff line number Diff line
@@ -68,12 +68,18 @@ class UniquePointer< Object, Devices::Host > : public SmartPointer
         return *( this->pointer );
      }
      
      operator bool()
      {
         return this->pointer;
      }

      template< typename Device = Devices::Host >
      const Object& getData() const
      {
         return *( this->pointer );
      }

      template< typename Device = Devices::Host >
      Object& modifyData()
      {
         return *( this->pointer );
@@ -150,6 +156,11 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer
         return *( this->pointer );
      }
      
      operator bool()
      {
         return this->pointer;
      }

      template< typename Device = Devices::Host >      
      const Object& getData() const
      {
@@ -160,11 +171,20 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer
            return *( this->cuda_pointer );            
      }

      template< typename Device = Devices::Host >
      Object& modifyData()
      {
         static_assert( std::is_same< Device, Devices::Host >::value || std::is_same< Device, Devices::Cuda >::value, "Only Devices::Host or Devices::Cuda devices are accepted here." );
         if( std::is_same< Device, Devices::Host >::value )
         {
            this->modified = true;
            return *( this->pointer );
         }
         if( std::is_same< Device, Devices::Cuda >::value )
         {
            return *( this->cuda_pointer );
         }
      }
      
      const ThisType& operator=( ThisType& ptr )
      {