Program Listing for File device_reference.h¶
↰ Return to documentation for file (thrust/device_reference.h)
/*
* Copyright 2008-2013 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/device_ptr.h>
#include <thrust/detail/type_traits.h>
#include <thrust/detail/reference.h>
namespace thrust
{
template<typename T>
class device_reference
: public thrust::reference<
T,
thrust::device_ptr<T>,
thrust::device_reference<T>
>
{
private:
typedef thrust::reference<
T,
thrust::device_ptr<T>,
thrust::device_reference<T>
> super_t;
public:
typedef typename super_t::value_type value_type;
typedef typename super_t::pointer pointer;
template<typename OtherT>
__host__ __device__
device_reference(const device_reference<OtherT> &other,
typename thrust::detail::enable_if_convertible<
typename device_reference<OtherT>::pointer,
pointer
>::type * = 0)
: super_t(other)
{}
__host__ __device__
explicit device_reference(const pointer &ptr)
: super_t(ptr)
{}
template<typename OtherT>
__host__ __device__
device_reference &operator=(const device_reference<OtherT> &other);
__host__ __device__
device_reference &operator=(const value_type &x);
// declare these members for the purpose of Doxygenating them
// they actually exist in a derived-from class
#if 0
__host__ __device__
pointer operator&(void) const;
__host__ __device__
operator value_type (void) const;
__host__ __device__
void swap(device_reference &other);
device_reference &operator++(void);
value_type operator++(int);
device_reference &operator+=(const T &rhs);
device_reference &operator--(void);
value_type operator--(int);
device_reference &operator-=(const T &rhs);
device_reference &operator*=(const T &rhs);
device_reference &operator/=(const T &rhs);
device_reference &operator%=(const T &rhs);
device_reference &operator<<=(const T &rhs);
device_reference &operator>>=(const T &rhs);
device_reference &operator&=(const T &rhs);
device_reference &operator|=(const T &rhs);
device_reference &operator^=(const T &rhs);
#endif // end doxygen-only members
}; // end device_reference
template<typename T>
__host__ __device__
void swap(device_reference<T> &x, device_reference<T> &y);
// declare these methods for the purpose of Doxygenating them
// they actually are defined for a derived-from class
#if 0
template<typename T, typename charT, typename traits>
std::basic_ostream<charT, traits> &
operator<<(std::basic_ostream<charT, traits> &os, const device_reference<T> &y);
#endif
} // end thrust
#include <thrust/detail/device_reference.inl>