/* * 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. */ #pragma once #include #include #include #include #include namespace thrust { namespace detail { __THRUST_DEFINE_HAS_NESTED_TYPE(is_wrapped_reference, wrapped_reference_hint) namespace raw_reference_detail { template struct raw_reference : add_reference {}; // XXX consider making raw_reference an error template struct raw_reference< T, typename thrust::detail::enable_if< is_wrapped_reference< typename remove_cv::type >::value >::type > { typedef typename add_reference< typename pointer_element::type >::type type; }; } // end raw_reference_ns template struct raw_reference : raw_reference_detail::raw_reference {}; // wrapped reference-like things which aren't strictly wrapped references // (e.g. tuples of wrapped references) are considered unwrappable template struct is_unwrappable : is_wrapped_reference {}; template struct enable_if_unwrappable : enable_if< is_unwrappable::value, Result > {}; } // end detail template inline __host__ __device__ typename detail::raw_reference::type raw_reference_cast(T &ref) { return *thrust::raw_pointer_cast(&ref); } // end raw_reference_cast template inline __host__ __device__ typename detail::raw_reference::type raw_reference_cast(const T &ref) { return *thrust::raw_pointer_cast(&ref); } // end raw_reference_cast template< typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9 > inline __host__ __device__ typename detail::enable_if_unwrappable< thrust::detail::tuple_of_iterator_references, typename detail::raw_reference< thrust::detail::tuple_of_iterator_references >::type >::type raw_reference_cast(detail::tuple_of_iterator_references t); } // end thrust #include