/*! @file Defines `boost::hana::length`. @copyright Louis Dionne 2013-2016 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_LENGTH_HPP #define BOOST_HANA_LENGTH_HPP #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN //! @cond template constexpr auto length_t::operator()(Xs const& xs) const { using S = typename hana::tag_of::type; using Length = BOOST_HANA_DISPATCH_IF(length_impl, hana::Foldable::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Foldable::value, "hana::length(xs) requires 'xs' to be Foldable"); #endif return Length::apply(xs); } //! @endcond namespace detail { struct argn { template constexpr hana::size_t operator()(Xs const& ...) const { return {}; } }; } template struct length_impl> : default_ { template static constexpr auto apply(Xs const& xs) { return hana::unpack(xs, detail::argn{}); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_LENGTH_HPP