@@ -23,8 +23,10 @@ Distributed under the Boost Software License, Version 1.0.
23
23
#include < boost/hana/detail/unpack_flatten.hpp>
24
24
#include < boost/hana/equal.hpp>
25
25
#include < boost/hana/fold_left.hpp>
26
+ #include < boost/hana/functional/apply.hpp>
26
27
#include < boost/hana/functional/compose.hpp>
27
28
#include < boost/hana/functional/on.hpp>
29
+ #include < boost/hana/fuse.hpp>
28
30
#include < boost/hana/fwd/ap.hpp>
29
31
#include < boost/hana/fwd/concat.hpp>
30
32
#include < boost/hana/fwd/core/make.hpp>
@@ -625,10 +627,14 @@ BOOST_HANA_NAMESPACE_BEGIN
625
627
template <>
626
628
struct ap_impl <hana::view_tag> {
627
629
template <typename F, typename X>
628
- static constexpr auto apply (F&& f, X&& x) {
629
- // TODO: Implement cleverly; we most likely need a cartesian_product
630
- // view or something like that.
631
- return hana::ap (hana::to_tuple (f), hana::to_tuple (x));
630
+ static constexpr auto apply (F f, X x) {
631
+ // Note: `f` and `x` must both be view, so we're not returning
632
+ // dangling references below.
633
+ auto fs = detail::single_view (f);
634
+ auto xs = detail::single_view (x);
635
+ auto joined = detail::joined (fs, xs);
636
+ auto product = detail::cartesian_product_view (joined);
637
+ return detail::transformed (product, hana::fuse (hana::apply));
632
638
}
633
639
};
634
640
@@ -669,7 +675,6 @@ BOOST_HANA_NAMESPACE_BEGIN
669
675
// ////////////////////////////////////////////////////////////////////////
670
676
// Comparable
671
677
// ////////////////////////////////////////////////////////////////////////
672
-
673
678
template <typename Xs, typename Ys>
674
679
inline constexpr auto equal_helper (Xs const & xs, Ys const & ys) {
675
680
constexpr std::size_t xs_size = decltype (hana::length (xs))::value;
0 commit comments