/* * 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. */ // Portions of this code are derived from // // Manjunath Kudlur's Carbon library // // and // // Based on Boost.Phoenix v1.2 // Copyright (c) 2001-2002 Joel de Guzman #pragma once #include #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) # pragma GCC system_header #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) # pragma clang system_header #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) # pragma system_header #endif // no system header #include #include #include #include #include THRUST_NAMESPACE_BEGIN namespace detail { namespace functional { template __host__ __device__ constexpr actor ::actor() : eval_type() {} template __host__ __device__ actor ::actor(const Eval &base) : eval_type(base) {} // actor::operator() needs to construct a tuple of references to its // arguments. To make this work with thrust::reference, we need to // detect thrust proxy references and store them as T rather than T&. // This check ensures that the forwarding references passed into // actor::operator() are either: // - T&& if and only if T is a thrust::reference, or // - T& for any other types. // This struct provides a nicer diagnostic for when these conditions aren't // met. template using actor_check_ref_type = ::cuda::std::integral_constant::value || thrust::detail::is_wrapped_reference::value )>; template using actor_check_ref_types = thrust::conjunction...>; template template __host__ __device__ typename apply_actor::eval_type, thrust::tuple...>>::type actor::operator()(Ts&&... ts) const { static_assert(actor_check_ref_types::value, "Actor evaluations only support rvalue references to " "thrust::reference subclasses."); using tuple_type = thrust::tuple...>; return eval_type::eval(tuple_type(THRUST_FWD(ts)...)); } // end actor::operator() template template __host__ __device__ typename assign_result::type actor ::operator=(const T& _1) const { return do_assign(*this,_1); } // end actor::operator=() } // end functional } // end detail THRUST_NAMESPACE_END