File indexing completed on 2025-01-18 09:38:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_FRONT_HPP
0011 #define BOOST_HANA_FRONT_HPP
0012
0013 #include <boost/hana/fwd/front.hpp>
0014
0015 #include <boost/hana/at.hpp>
0016 #include <boost/hana/concept/iterable.hpp>
0017 #include <boost/hana/config.hpp>
0018 #include <boost/hana/core/dispatch.hpp>
0019
0020
0021 namespace boost { namespace hana {
0022
0023 template <typename Xs>
0024 constexpr decltype(auto) front_t::operator()(Xs&& xs) const {
0025 using It = typename hana::tag_of<Xs>::type;
0026 using Front = BOOST_HANA_DISPATCH_IF(front_impl<It>,
0027 hana::Iterable<It>::value
0028 );
0029
0030 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0031 static_assert(hana::Iterable<It>::value,
0032 "hana::front(xs) requires 'xs' to be an Iterable");
0033 #endif
0034
0035 return Front::apply(static_cast<Xs&&>(xs));
0036 }
0037
0038
0039 template <typename It, bool condition>
0040 struct front_impl<It, when<condition>> : default_ {
0041 template <typename Xs>
0042 static constexpr decltype(auto) apply(Xs&& xs)
0043 { return hana::at_c<0>(static_cast<Xs&&>(xs)); }
0044 };
0045 }}
0046
0047 #endif