/* * 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. */ // 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 #include #include #include #include #include namespace thrust { namespace detail { namespace functional { template struct apply_actor { typedef typename Action::template result::type type; }; template struct actor : Eval { typedef Eval eval_type; __host__ __device__ actor(void); __host__ __device__ actor(const Eval &base); __host__ __device__ typename apply_actor::type operator()(void) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6, T7 &_7) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6, T7 &_7, T8 &_8) const; template __host__ __device__ typename apply_actor >::type operator()(T0 &_0, T1 &_1, T2 &_2, T3 &_3, T4 &_4, T5 &_5, T6 &_6, T7 &_7, T8 &_8, T9 &_9) 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< thrust::detail::functional::actor() > { typedef typename thrust::detail::functional::apply_actor< thrust::detail::functional::actor, thrust::null_type >::type type; }; // end result_of template struct result_of< 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< 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 } // end thrust #include