/* * Copyright 2008-2012 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. */ #include #include namespace thrust { template pointer ::pointer() : super_t(static_cast(0)) {} // end pointer::pointer template template pointer ::pointer(OtherElement *other) : super_t(other) {} // end pointer::pointer template template pointer ::pointer(const OtherPointer &other, typename thrust::detail::enable_if_pointer_is_convertible< OtherPointer, pointer >::type *) : super_t(thrust::detail::pointer_traits::get(other)) {} // end pointer::pointer template template typename thrust::detail::enable_if_pointer_is_convertible< OtherPointer, pointer, typename pointer::derived_type & >::type pointer ::operator=(const OtherPointer &other) { super_t::base_reference() = thrust::detail::pointer_traits::get(other); return static_cast(*this); } // end pointer::operator= template typename pointer::super_t::reference pointer ::dereference() const { return typename super_t::reference(static_cast(*this)); } // end pointer::dereference template Element *pointer ::get() const { return super_t::base(); } // end pointer::get namespace detail { #if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC) && (_MSC_VER <= 1400) // XXX WAR MSVC 2005 problem with correctly implementing // pointer_raw_pointer for pointer by specializing it here template struct pointer_raw_pointer< thrust::pointer > { typedef typename pointer::raw_pointer type; }; // end pointer_raw_pointer #endif #if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) && (THRUST_GCC_VERSION < 40200) // XXX WAR g++-4.1 problem with correctly implementing // pointer_element for pointer by specializing it here template struct pointer_element< thrust::pointer > { typedef Element type; }; // end pointer_element template struct pointer_element< thrust::pointer > : pointer_element< thrust::pointer > {}; // end pointer_element template struct pointer_element< thrust::pointer > : pointer_element< thrust::pointer > {}; // end pointer_element // XXX WAR g++-4.1 problem with correctly implementing // rebind_pointer for pointer by specializing it here template struct rebind_pointer, NewElement> { // XXX note we don't attempt to rebind the pointer's Reference type (or Derived) typedef thrust::pointer type; }; template struct rebind_pointer, NewElement> : rebind_pointer, NewElement> {}; template struct rebind_pointer, NewElement> : rebind_pointer, NewElement> {}; #endif } // end namespace detail } // end thrust