1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_LAMBDA_MAKE_PAIR_HPP
12 #define BOOST_COMPUTE_LAMBDA_MAKE_PAIR_HPP
14 #include <boost/compute/types/pair.hpp>
21 // function wrapper for make_pair() in lambda expressions
24 template<class Expr, class Args>
27 typedef typename proto::result_of::child_c<Expr, 1>::type Arg1;
28 typedef typename proto::result_of::child_c<Expr, 2>::type Arg2;
30 typedef typename lambda::result_of<Arg1, Args>::type T1;
31 typedef typename lambda::result_of<Arg2, Args>::type T2;
33 typedef std::pair<T1, T2> type;
36 template<class Context, class Arg1, class Arg2>
37 static void apply(Context &ctx, const Arg1 &arg1, const Arg2 &arg2)
39 typedef typename lambda::result_of<Arg1, typename Context::args_tuple>::type T1;
40 typedef typename lambda::result_of<Arg2, typename Context::args_tuple>::type T2;
42 ctx.stream << "boost_make_pair(";
43 ctx.stream << type_name<T1>() << ", ";
44 proto::eval(arg1, ctx);
46 ctx.stream << type_name<T2>() << ", ";
47 proto::eval(arg2, ctx);
52 } // end detail namespace
54 // make_pair(first, second)
55 template<class Arg1, class Arg2>
56 inline typename proto::result_of::make_expr<
57 proto::tag::function, detail::make_pair_func, const Arg1&, const Arg2&
59 make_pair(const Arg1 &first, const Arg2 &second)
61 return proto::make_expr<proto::tag::function>(
62 detail::make_pair_func(), ::boost::ref(first), ::boost::ref(second)
66 } // end lambda namespace
67 } // end compute namespace
68 } // end boost namespace
70 #endif // BOOST_COMPUTE_LAMBDA_MAKE_PAIR_HPP