/*! @file Defines `boost::hana::count`. @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_COUNT_HPP #define BOOST_HANA_COUNT_HPP #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN //! @cond template constexpr auto count_t::operator()(Xs&& xs, Value&& value) const { using S = typename hana::tag_of::type; using Count = BOOST_HANA_DISPATCH_IF(count_impl, hana::Foldable::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Foldable::value, "hana::count(xs, value) requires 'xs' to be Foldable"); #endif return Count::apply(static_cast(xs), static_cast(value)); } //! @endcond template struct count_impl> : default_ { template static constexpr auto apply(Xs&& xs, Value&& value) { return hana::count_if(static_cast(xs), hana::equal.to(static_cast(value))); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_COUNT_HPP