File indexing completed on 2025-01-18 09:30:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_LAMBDA_PLACEHOLDERS_HPP
0012 #define BOOST_COMPUTE_LAMBDA_PLACEHOLDERS_HPP
0013
0014 #include <boost/mpl/has_xxx.hpp>
0015
0016 #include <boost/compute/lambda/context.hpp>
0017 #include <boost/compute/lambda/result_of.hpp>
0018
0019 namespace boost {
0020 namespace compute {
0021 namespace lambda {
0022
0023 namespace mpl = boost::mpl;
0024 namespace proto = boost::proto;
0025
0026
0027 expression<proto::terminal<placeholder<0> >::type> const _1;
0028 expression<proto::terminal<placeholder<1> >::type> const _2;
0029 expression<proto::terminal<placeholder<2> >::type> const _3;
0030
0031 namespace detail {
0032
0033 BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
0034
0035 template<class T, bool HasResultType>
0036 struct terminal_type_impl;
0037
0038 template<class T>
0039 struct terminal_type_impl<T, true>
0040 {
0041 typedef typename T::result_type type;
0042 };
0043
0044 template<class T>
0045 struct terminal_type_impl<T, false>
0046 {
0047 typedef T type;
0048 };
0049
0050 template<class T>
0051 struct terminal_type
0052 {
0053 typedef typename terminal_type_impl<T, has_result_type<T>::value>::type type;
0054 };
0055
0056 }
0057
0058
0059 template<class Args>
0060 struct result_of<expression<proto::terminal<placeholder<0> >::type>, Args, proto::tag::terminal>
0061 {
0062 typedef typename boost::tuples::element<0, Args>::type arg_type;
0063
0064 typedef typename detail::terminal_type<arg_type>::type type;
0065 };
0066
0067 template<class Args>
0068 struct result_of<expression<proto::terminal<placeholder<1> >::type>, Args, proto::tag::terminal>
0069 {
0070 typedef typename boost::tuples::element<1, Args>::type arg_type;
0071
0072 typedef typename detail::terminal_type<arg_type>::type type;
0073 };
0074
0075 template<class Args>
0076 struct result_of<expression<proto::terminal<placeholder<2> >::type>, Args, proto::tag::terminal>
0077 {
0078 typedef typename boost::tuples::element<2, Args>::type arg_type;
0079
0080 typedef typename detail::terminal_type<arg_type>::type type;
0081 };
0082
0083 }
0084
0085
0086 using lambda::_1;
0087 using lambda::_2;
0088 using lambda::_3;
0089
0090 }
0091 }
0092
0093 #endif