/*! @file Defines `boost::hana::count`. @copyright Louis Dionne 2013-2017 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 namespace boost { namespace hana { //! @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))); } }; }} // end namespace boost::hana #endif // !BOOST_HANA_COUNT_HPP