]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/fwd/if.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / if.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::if_`.
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_FWD_IF_HPP
11 #define BOOST_HANA_FWD_IF_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Conditionally return one of two values based on a condition.
19 //! @ingroup group-Logical
20 //!
21 //! Specifically, `then` is returned iff `cond` is true-valued, and
22 //! `else_` is returned otherwise. Note that some `Logical` models may
23 //! allow `then` and `else_` to have different types, while others may
24 //! require both values to have the same type.
25 //!
26 //!
27 //! @param cond
28 //! The condition determining which of the two values is returned.
29 //!
30 //! @param then
31 //! The value returned when `cond` is true-valued.
32 //!
33 //! @param else_
34 //! The value returned when `cond` is false-valued.
35 //!
36 //!
37 //! Example
38 //! -------
39 //! @include example/if.cpp
40 #ifdef BOOST_HANA_DOXYGEN_INVOKED
41 constexpr auto if_ = [](auto&& cond, auto&& then, auto&& else_) -> decltype(auto) {
42 return tag-dispatched;
43 };
44 #else
45 template <typename L, typename = void>
46 struct if_impl : if_impl<L, when<true>> { };
47
48 struct if_t {
49 template <typename Cond, typename Then, typename Else>
50 constexpr decltype(auto) operator()(Cond&& cond, Then&& then, Else&& else_) const;
51 };
52
53 constexpr if_t if_{};
54 #endif
55 BOOST_HANA_NAMESPACE_END
56
57 #endif // !BOOST_HANA_FWD_IF_HPP