//---------------------------------------------------------------------------// // Copyright (c) 2013-2014 Kyle Lutz // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://boostorg.github.com/compute for more information. //---------------------------------------------------------------------------// #ifndef BOOST_COMPUTE_LAMBDA_MAKE_PAIR_HPP #define BOOST_COMPUTE_LAMBDA_MAKE_PAIR_HPP #include namespace boost { namespace compute { namespace lambda { namespace detail { // function wrapper for make_pair() in lambda expressions struct make_pair_func { template struct lambda_result { typedef typename proto::result_of::child_c::type Arg1; typedef typename proto::result_of::child_c::type Arg2; typedef typename lambda::result_of::type T1; typedef typename lambda::result_of::type T2; typedef std::pair type; }; template static void apply(Context &ctx, const Arg1 &arg1, const Arg2 &arg2) { typedef typename lambda::result_of::type T1; typedef typename lambda::result_of::type T2; ctx.stream << "boost_make_pair("; ctx.stream << type_name() << ", "; proto::eval(arg1, ctx); ctx.stream << ", "; ctx.stream << type_name() << ", "; proto::eval(arg2, ctx); ctx.stream << ")"; } }; } // end detail namespace // make_pair(first, second) template inline typename proto::result_of::make_expr< proto::tag::function, detail::make_pair_func, const Arg1&, const Arg2& >::type const make_pair(const Arg1 &first, const Arg2 &second) { return proto::make_expr( detail::make_pair_func(), ::boost::ref(first), ::boost::ref(second) ); } } // end lambda namespace } // end compute namespace } // end boost namespace #endif // BOOST_COMPUTE_LAMBDA_MAKE_PAIR_HPP