]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/front.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / front.hpp
1 /*!
2 @file
3 Defines `boost::hana::front`.
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_FRONT_HPP
11 #define BOOST_HANA_FRONT_HPP
12
13 #include <boost/hana/fwd/front.hpp>
14
15 #include <boost/hana/at.hpp>
16 #include <boost/hana/concept/iterable.hpp>
17 #include <boost/hana/config.hpp>
18 #include <boost/hana/core/dispatch.hpp>
19
20
21 BOOST_HANA_NAMESPACE_BEGIN
22 //! @cond
23 template <typename Xs>
24 constexpr decltype(auto) front_t::operator()(Xs&& xs) const {
25 using It = typename hana::tag_of<Xs>::type;
26 using Front = BOOST_HANA_DISPATCH_IF(front_impl<It>,
27 hana::Iterable<It>::value
28 );
29
30 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
31 static_assert(hana::Iterable<It>::value,
32 "hana::front(xs) requires 'xs' to be an Iterable");
33 #endif
34
35 return Front::apply(static_cast<Xs&&>(xs));
36 }
37 //! @endcond
38
39 template <typename It, bool condition>
40 struct front_impl<It, when<condition>> : default_ {
41 template <typename Xs>
42 static constexpr decltype(auto) apply(Xs&& xs)
43 { return hana::at_c<0>(static_cast<Xs&&>(xs)); }
44 };
45 BOOST_HANA_NAMESPACE_END
46
47 #endif // !BOOST_HANA_FRONT_HPP