39 #ifndef ECUDA_PTR_PADDED_PTR_HPP
40 #define ECUDA_PTR_PADDED_PTR_HPP
44 #include "../global.hpp"
45 #include "../type_traits.hpp"
46 #include "../utility.hpp"
78 template<typename T,class P=typename ecuda::add_pointer<T>::type>
90 template<
typename U>
struct char_pointer;
91 template<
typename U>
struct char_pointer<U*> {
typedef char* type; };
92 template<
typename U>
struct char_pointer<const U*> {
typedef const char* type; };
93 template<
typename U>
__HOST__ __DEVICE__ typename char_pointer<U*>::type char_cast( U* ptr )
const {
return reinterpret_cast<char*
>(ptr); }
94 template<
typename U>
__HOST__ __DEVICE__ typename char_pointer<const U*>::type char_cast(
const U* ptr )
const {
return reinterpret_cast<const char*
>(ptr); }
112 template<
typename T2,
class P2>
115 #ifdef ECUDA_CPP11_AVAILABLE
119 ptr = std::move(src.ptr);
120 pitch = std::move(src.pitch);
134 #ifdef ECUDA_CPP11_AVAILABLE
135 __HOST__ __DEVICE__ explicit operator bool() const
__NOEXCEPT__ {
return naked_cast<
typename ecuda::add_pointer<const element_type>::type>( ptr ) != NULL; }
142 __HOST__ __DEVICE__ operator bool() const
__NOEXCEPT__ {
return naked_cast<
typename ecuda::add_pointer<const element_type>::type>( ptr ) != NULL; }
178 template<
typename T2,
typename P2>
__HOST__ __DEVICE__ bool operator< ( const padded_ptr<T2,P2>& other )
const {
return ptr < other.ptr; }
180 template<
typename T2,
typename P2>
__HOST__ __DEVICE__ bool operator<=( const padded_ptr<T2,P2>& other )
const {
return ptr <= other.ptr; }
193 typedef typename ecuda::add_pointer<element_type>::type raw_pointer_type;
194 typedef typename char_pointer<raw_pointer_type>::type char_pointer_type;
195 char_pointer_type charPtr = char_cast( naked_cast<raw_pointer_type>(ptr) );
197 ptr =
pointer( naked_cast<raw_pointer_type>(charPtr) );
200 template<
typename U,
typename V>
201 friend std::basic_ostream<U,V>& operator<<( std::basic_ostream<U,V>& out,
const padded_ptr& ptr )
203 out <<
"padded_ptr(ptr=" << ptr.ptr <<
";pitch=" << ptr.pitch <<
")";
__HOST__ __DEVICE__ void skip_bytes(difference_type x)
Move the pointer some number of bytes.
__HOST__ __DEVICE__ padded_ptr operator+(int x) const
__HOST__ __DEVICE__ bool operator>=(const padded_ptr< T2, P2 > &other) const
__HOST__ __DEVICE__ bool operator==(const padded_ptr< T2, P2 > &other) const
__HOST__ __DEVICE__ padded_ptr operator-(std::size_t x) const
__HOST__ __DEVICE__ padded_ptr(pointer ptr=pointer(), size_type pitch=size_type())
__HOST__ __DEVICE__ padded_ptr operator-(int x) const
const T & const_reference
__HOST__ __DEVICE__ padded_ptr & operator++()
__DEVICE__ reference operator*()
__HOST__ __DEVICE__ bool operator>(const padded_ptr< T2, P2 > &other) const
__DEVICE__ pointer operator->() const
__HOST__ __DEVICE__ padded_ptr operator+(std::size_t x) const
A specialized pointer to padded memory.
__HOST__ __DEVICE__ pointer get() const
__DEVICE__ const_reference operator[](std::size_t i) const
__HOST__ __DEVICE__ padded_ptr(const padded_ptr< T2, P2 > &src)
__HOST__ __DEVICE__ padded_ptr & operator-=(int x)
__HOST__ __DEVICE__ padded_ptr operator++(int)
__HOST__ __DEVICE__ padded_ptr & operator+=(int x)
__HOST__ __DEVICE__ padded_ptr & operator--()
__HOST__ __DEVICE__ size_type get_pitch() const
__HOST__ __DEVICE__ bool operator!=(const padded_ptr< T2, P2 > &other) const
__DEVICE__ const_reference operator*() const
__HOST__ __DEVICE__ padded_ptr(const padded_ptr &src)
__HOST__ __DEVICE__ padded_ptr & operator=(const padded_ptr &src)
__HOST__ __DEVICE__ padded_ptr operator--(int)
__DEVICE__ reference operator[](std::size_t i)
std::ptrdiff_t difference_type