3 Forward declares `boost::hana::comparing`.
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)
10 #ifndef BOOST_HANA_FWD_COMPARING_HPP
11 #define BOOST_HANA_FWD_COMPARING_HPP
13 #include <boost/hana/config.hpp>
16 namespace boost { namespace hana {
17 //! Returns a function performing `equal` after applying a transformation
18 //! to both arguments.
19 //! @ingroup group-Comparable
21 //! `comparing` creates an equivalence relation based on the result of
22 //! applying a function to some objects, which is especially useful in
23 //! conjunction with algorithms that accept a custom predicate that must
24 //! represent an equivalence relation.
26 //! Specifically, `comparing` is such that
28 //! comparing(f) == equal ^on^ f
32 //! comparing(f)(x, y) == equal(f(x), f(y))
36 //! This is not a tag-dispatched method (hence it can't be customized),
37 //! but just a convenience function provided with the `Comparable` concept.
42 //! Given a Logical `Bool` and a Comparable `B`, the signature is
43 //! @f$ \mathtt{comparing} : (A \to B) \to (A \times A \to Bool) @f$.
48 //! @include example/comparing.cpp
49 #ifdef BOOST_HANA_DOXYGEN_INVOKED
50 constexpr auto comparing = [](auto&& f) {
51 return [perfect-capture](auto&& x, auto&& y) {
52 return equal(f(forwarded(x)), f(forwarded(y)));
58 constexpr auto operator()(F&& f) const;
61 BOOST_HANA_INLINE_VARIABLE constexpr comparing_t comparing{};
63 }} // end namespace boost::hana
65 #endif // !BOOST_HANA_FWD_COMPARING_HPP