]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/detail/nested_to_fwd.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / detail / nested_to_fwd.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::detail::nested_to`.
4
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)
8 */
9
10 #ifndef BOOST_HANA_DETAIL_NESTED_TO_FWD_HPP
11 #define BOOST_HANA_DETAIL_NESTED_TO_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_to_t {
19 template <typename X>
20 constexpr decltype(auto) operator()(X&& x) const;
21 };
22
23 //! @ingroup group-details
24 //! Provides a `.to` static constexpr function object.
25 //!
26 //! When creating a binary function object of type `Algo` whose signature
27 //! is `Object x Object -> Return`, `nested_to<Algo>` can be used as a base
28 //! class of `Algo`. Doing so will provide a static constexpr member called
29 //! `to`, which has the following signature:
30 //! @code
31 //! Object -> Object -> Return
32 //! @endcode
33 //!
34 //! Note that the function object `Algo` must be default-constructible,
35 //! since the algorithm 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_to { static constexpr nested_to_t<Algorithm> to{}; };
42
43 template <typename Algorithm>
44 constexpr nested_to_t<Algorithm> nested_to<Algorithm>::to;
45 } BOOST_HANA_NAMESPACE_END
46
47 #endif // !BOOST_HANA_DETAIL_NESTED_TO_FWD_HPP