1 /*!
2 @file
3 Forward declares `boost::hana::detail::nested_than`.
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_THAN_FWD_HPP
11 #define BOOST_HANA_DETAIL_NESTED_THAN_FWD_HPP
12 
13 #include <boost/hana/config.hpp>
14 
15 
16 BOOST_HANA_NAMESPACE_BEGIN namespace detail {
17     template <typename Algorithm>
18     struct nested_than_t {
19         template <typename X>
20         constexpr decltype(auto) operator()(X&& x) const;
21     };
22 
23     //! @ingroup group-details
24     //! Provides a `.than` static constexpr function object.
25     //!
26     //! When creating a binary function object of type `Algo` whose signature
27     //! is `A x B -> Return`, `nested_than<Algo>` can be used as a base class
28     //! of `Algo`. Doing so will provide a static constexpr member called
29     //! `than`, which has the following signature:
30     //! @code
31     //!     B -> A -> Return
32     //! @endcode
33     //!
34     //! Note that the function object `Algo` must be default-constructible,
35     //! since it will be called as `Algo{}(arguments...)`.
36     //!
37     //! @note
38     //! This function object is especially useful because it takes care of
39     //! avoiding ODR violations caused by the nested static constexpr member.
40     template <typename Algorithm>
41     struct nested_than { static constexpr nested_than_t<Algorithm> than{}; };
42 
43     template <typename Algorithm>
44     constexpr nested_than_t<Algorithm> nested_than<Algorithm>::than;
45 } BOOST_HANA_NAMESPACE_END
46 
47 #endif // !BOOST_HANA_DETAIL_NESTED_THAN_FWD_HPP
48