Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / hana / detail / nested_by.hpp
1 /*!
2 @file
3 Defines `boost::hana::detail::nested_by`.
4
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8  */
9
10 #ifndef BOOST_HANA_DETAIL_NESTED_BY_HPP
11 #define BOOST_HANA_DETAIL_NESTED_BY_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/detail/nested_by_fwd.hpp>
15
16 #include <boost/hana/functional/flip.hpp>
17 #include <boost/hana/functional/partial.hpp>
18
19
20 BOOST_HANA_NAMESPACE_BEGIN namespace detail {
21     //! @cond
22     template <typename Algorithm>
23     template <typename Predicate, typename Object>
24     constexpr decltype(auto) nested_by_t<Algorithm>::
25     operator()(Predicate&& predicate, Object&& object) const {
26         return Algorithm{}(static_cast<Object&&>(object),
27                            static_cast<Predicate&&>(predicate));
28     }
29
30     template <typename Algorithm>
31     template <typename Predicate>
32     constexpr decltype(auto)
33     nested_by_t<Algorithm>::operator()(Predicate&& predicate) const {
34         return hana::partial(hana::flip(Algorithm{}),
35                              static_cast<Predicate&&>(predicate));
36     }
37     //! @endcond
38 } BOOST_HANA_NAMESPACE_END
39
40 #endif // !BOOST_HANA_DETAIL_NESTED_BY_HPP