OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / detail / device_ptr.inl
1 /*
2  *  Copyright 2008-2013 NVIDIA Corporation
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17
18 /*! \file device_ptr.inl
19  *  \brief Inline file for device_ptr.h.
20  */
21
22 #include <thrust/device_ptr.h>
23 #include <thrust/device_reference.h>
24 #include <iostream>
25
26 #include <thrust/detail/type_traits.h>
27 #include <thrust/iterator/iterator_traits.h>
28
29 namespace thrust
30 {
31
32 template<typename T>
33   device_ptr<T> device_pointer_cast(T *ptr)
34 {
35   return device_ptr<T>(ptr);
36 } // end device_pointer_cast()
37
38 template<typename T>
39   device_ptr<T> device_pointer_cast(const device_ptr<T> &ptr)
40 {
41   return ptr;
42 } // end device_pointer_cast()
43
44 // output to ostream
45 template<class E, class T, class Y>
46   std::basic_ostream<E, T> &operator<<(std::basic_ostream<E, T> &os, const device_ptr<Y> &p)
47 {
48   return os << p.get();
49 } // end operator<<()
50
51
52 namespace detail
53 {
54
55 template<typename T>
56   struct is_device_ptr< thrust::device_ptr<T> >
57     : public true_type
58 {
59 }; // end is_device_ptr
60
61 #if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && (_MSC_VER <= 1400)
62 // XXX WAR MSVC 2005 problem with correctly implementing
63 //     pointer_raw_pointer for device_ptr by specializing it here
64 template<typename T>
65   struct pointer_raw_pointer< thrust::device_ptr<T> >
66 {
67   typedef typename device_ptr<T>::raw_pointer type;
68 }; // end pointer_raw_pointer
69 #endif
70
71
72 } // end namespace detail
73 } // end namespace thrust
74