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_MAKE_PAIR_HPP
0012 #define BOOST_COMPUTE_LAMBDA_MAKE_PAIR_HPP
0013
0014 #include <boost/compute/types/pair.hpp>
0015
0016 namespace boost {
0017 namespace compute {
0018 namespace lambda {
0019 namespace detail {
0020
0021
0022 struct make_pair_func
0023 {
0024 template<class Expr, class Args>
0025 struct lambda_result
0026 {
0027 typedef typename proto::result_of::child_c<Expr, 1>::type Arg1;
0028 typedef typename proto::result_of::child_c<Expr, 2>::type Arg2;
0029
0030 typedef typename lambda::result_of<Arg1, Args>::type T1;
0031 typedef typename lambda::result_of<Arg2, Args>::type T2;
0032
0033 typedef std::pair<T1, T2> type;
0034 };
0035
0036 template<class Context, class Arg1, class Arg2>
0037 static void apply(Context &ctx, const Arg1 &arg1, const Arg2 &arg2)
0038 {
0039 typedef typename lambda::result_of<Arg1, typename Context::args_tuple>::type T1;
0040 typedef typename lambda::result_of<Arg2, typename Context::args_tuple>::type T2;
0041
0042 ctx.stream << "boost_make_pair(";
0043 ctx.stream << type_name<T1>() << ", ";
0044 proto::eval(arg1, ctx);
0045 ctx.stream << ", ";
0046 ctx.stream << type_name<T2>() << ", ";
0047 proto::eval(arg2, ctx);
0048 ctx.stream << ")";
0049 }
0050 };
0051
0052 }
0053
0054
0055 template<class Arg1, class Arg2>
0056 inline typename proto::result_of::make_expr<
0057 proto::tag::function, detail::make_pair_func, const Arg1&, const Arg2&
0058 >::type const
0059 make_pair(const Arg1 &first, const Arg2 &second)
0060 {
0061 return proto::make_expr<proto::tag::function>(
0062 detail::make_pair_func(), ::boost::ref(first), ::boost::ref(second)
0063 );
0064 }
0065
0066 }
0067 }
0068 }
0069
0070 #endif