/* * 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 #include THRUST_NAMESPACE_BEGIN namespace detail { namespace functional { // eval_ref is // - T when T is a subclass of thrust::reference // - T& otherwise // This is used to let thrust::references pass through actor evaluations. template using eval_ref = typename std::conditional< thrust::detail::is_wrapped_reference::value, T, T&>::type; template struct apply_actor { typedef typename Action::template result::type type; }; template struct actor : Eval { typedef Eval eval_type; __host__ __device__ constexpr actor(); __host__ __device__ actor(const Eval &base); template __host__ __device__ typename apply_actor...>>::type operator()(Ts&&... ts) const; template __host__ __device__ typename assign_result::type operator=(const T &_1) const; }; // end actor // in general, as_actor should turn things into values template struct as_actor { typedef value type; static inline __host__ __device__ type convert(const T &x) { return val(x); } // end convert() }; // end as_actor // specialization for things which are already actors template struct as_actor > { typedef actor type; static inline __host__ __device__ const type &convert(const actor &x) { return x; } // end convert() }; // end as_actor template typename as_actor::type __host__ __device__ make_actor(const T &x) { return as_actor::convert(x); } // end make_actor() } // end functional // provide specializations for result_of for nullary, unary, and binary invocations of actor template struct result_of_adaptable_function< thrust::detail::functional::actor() > { typedef typename thrust::detail::functional::apply_actor< thrust::detail::functional::actor, thrust::tuple<> >::type type; }; // end result_of template struct result_of_adaptable_function< thrust::detail::functional::actor(Arg1) > { typedef typename thrust::detail::functional::apply_actor< thrust::detail::functional::actor, thrust::tuple >::type type; }; // end result_of template struct result_of_adaptable_function< thrust::detail::functional::actor(Arg1,Arg2) > { typedef typename thrust::detail::functional::apply_actor< thrust::detail::functional::actor, thrust::tuple >::type type; }; // end result_of } // end detail THRUST_NAMESPACE_END #include