/*! @file Defines `boost::hana::is_subset`. @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_IS_SUBSET_HPP #define BOOST_HANA_IS_SUBSET_HPP #include #include #include #include #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN //! @cond template constexpr auto is_subset_t::operator()(Xs&& xs, Ys&& ys) const { using S1 = typename hana::tag_of::type; using S2 = typename hana::tag_of::type; using IsSubset = BOOST_HANA_DISPATCH_IF( decltype(is_subset_impl{}), hana::Searchable::value && hana::Searchable::value && !is_default>::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Searchable::value, "hana::is_subset(xs, ys) requires 'xs' to be Searchable"); static_assert(hana::Searchable::value, "hana::is_subset(xs, ys) requires 'ys' to be Searchable"); static_assert(!is_default>::value, "hana::is_subset(xs, ys) requires 'xs' and 'ys' to be embeddable " "in a common Searchable"); #endif return IsSubset::apply(static_cast(xs), static_cast(ys)); } //! @endcond template struct is_subset_impl> : default_ { template static constexpr auto apply(Args&& ...) = delete; }; template struct is_subset_impl> { template static constexpr decltype(auto) apply(Xs&& xs, Ys&& ys) { return hana::all_of(static_cast(xs), hana::partial(hana::contains, static_cast(ys))); } }; // Cross-type overload template struct is_subset_impl::value >> { using C = typename common::type; template static constexpr decltype(auto) apply(Xs&& xs, Ys&& ys) { return hana::is_subset(hana::to(static_cast(xs)), hana::to(static_cast(ys))); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_IS_SUBSET_HPP