]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/hana/front.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / hana / front.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::front`.
4
b32b8144 5@copyright Louis Dionne 2013-2017
7c673cae
FG
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_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
1e59de90 21namespace boost { namespace hana {
7c673cae
FG
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 };
1e59de90 45}} // end namespace boost::hana
7c673cae
FG
46
47#endif // !BOOST_HANA_FRONT_HPP