]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/min.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / min.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::min`.
4
5@copyright Louis Dionne 2013-2016
6Distributed 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_MIN_HPP
11#define BOOST_HANA_MIN_HPP
12
13#include <boost/hana/fwd/min.hpp>
14
15#include <boost/hana/concept/orderable.hpp>
16#include <boost/hana/config.hpp>
17#include <boost/hana/core/dispatch.hpp>
18#include <boost/hana/if.hpp>
19#include <boost/hana/less.hpp>
20
21
22BOOST_HANA_NAMESPACE_BEGIN
23 //! @cond
24 template <typename X, typename Y>
25 constexpr decltype(auto) min_t::operator()(X&& x, Y&& y) const {
26 using T = typename hana::tag_of<X>::type;
27 using U = typename hana::tag_of<Y>::type;
28 using Min = BOOST_HANA_DISPATCH_IF(decltype(min_impl<T, U>{}),
29 hana::Orderable<T>::value &&
30 hana::Orderable<U>::value
31 );
32
33 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
34 static_assert(hana::Orderable<T>::value,
35 "hana::min(x, y) requires 'x' to be Orderable");
36
37 static_assert(hana::Orderable<U>::value,
38 "hana::min(x, y) requires 'y' to be Orderable");
39 #endif
40
41 return Min::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
42 }
43 //! @endcond
44
45 template <typename T, typename U, bool condition>
46 struct min_impl<T, U, when<condition>> : default_ {
47 template <typename X, typename Y>
48 static constexpr decltype(auto) apply(X&& x, Y&& y) {
49 decltype(auto) cond = hana::less(x, y);
50 return hana::if_(static_cast<decltype(cond)&&>(cond),
51 static_cast<X&&>(x),
52 static_cast<Y&&>(y)
53 );
54 }
55 };
56BOOST_HANA_NAMESPACE_END
57
58#endif // !BOOST_HANA_MIN_HPP