Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:03

0001 /*!
0002 @file
0003 Defines `boost::hana::front`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
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     //! @cond
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     //! @endcond
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 }} // end namespace boost::hana
0046 
0047 #endif // !BOOST_HANA_FRONT_HPP