3 Forward declares `boost::hana::detail::nested_by`.
5 @copyright Louis Dionne 2013-2016
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)
10 #ifndef BOOST_HANA_DETAIL_NESTED_BY_FWD_HPP
11 #define BOOST_HANA_DETAIL_NESTED_BY_FWD_HPP
13 #include <boost/hana/config.hpp>
16 BOOST_HANA_NAMESPACE_BEGIN namespace detail {
17 template <typename Algorithm>
19 template <typename Predicate, typename Object>
20 constexpr decltype(auto)
21 operator()(Predicate&& predicate, Object&& object) const;
23 template <typename Predicate>
24 constexpr decltype(auto) operator()(Predicate&& predicate) const;
27 //! @ingroup group-details
28 //! Provides a `.by` static constexpr function object.
30 //! When creating a binary function object of type `Algorithm` whose
31 //! signature is `Object x Predicate -> Return`, `nested_by<Algorithm>`
32 //! can be used as a base class to `Algorithm`. Doing so will provide a
33 //! static constexpr member called `by`, which has the two following
36 //! Predicate x Object -> Return
37 //! Predicate -> (Object -> Return)
40 //! In other words, `nested_by` is a `curry`ed and `flip`ped version of
41 //! `Algorithm`. Note that the function object `Algorithm` must be
42 //! default-constructible, since the algorithm will be called as
43 //! `Algorithm{}(arguments...)`.
46 //! This function object is especially useful because it takes care of
47 //! avoiding ODR violations caused by the nested static constexpr member.
48 template <typename Algorithm>
49 struct nested_by { static constexpr nested_by_t<Algorithm> by{}; };
51 template <typename Algorithm>
52 constexpr nested_by_t<Algorithm> nested_by<Algorithm>::by;
53 } BOOST_HANA_NAMESPACE_END
55 #endif // !BOOST_HANA_DETAIL_NESTED_BY_FWD_HPP