/* * 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::value, T, T&>::type; template struct apply_actor { typedef typename Action::template result::type type; }; template struct actor : Eval { typedef Eval eval_type; constexpr actor() = default; _CCCL_HOST_DEVICE actor(const Eval& base); template _CCCL_HOST_DEVICE typename apply_actor...>>::type operator()(Ts&&... ts) const; template _CCCL_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 _CCCL_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 _CCCL_HOST_DEVICE const type& convert(const actor& x) { return x; } // end convert() }; // end as_actor template typename as_actor::type _CCCL_HOST_DEVICE make_actor(const T& x) { return as_actor::convert(x); } // end make_actor() } // namespace functional // provide specializations for result_of for nullary, unary, and binary invocations of actor template struct result_of_adaptable_function()> { typedef typename thrust::detail::functional::apply_actor, thrust::tuple<>>::type type; }; // end result_of template struct result_of_adaptable_function(Arg1)> { typedef typename thrust::detail::functional::apply_actor, thrust::tuple>::type type; }; // end result_of template struct result_of_adaptable_function(Arg1, Arg2)> { typedef typename thrust::detail::functional::apply_actor, thrust::tuple>::type type; }; // end result_of } // namespace detail THRUST_NAMESPACE_END #include