is_empty.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*!
  2. @file
  3. Defines `boost::hana::is_empty`.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_IS_EMPTY_HPP
  9. #define BOOST_HANA_IS_EMPTY_HPP
  10. #include <boost/hana/fwd/is_empty.hpp>
  11. #include <boost/hana/concept/iterable.hpp>
  12. #include <boost/hana/config.hpp>
  13. #include <boost/hana/core/dispatch.hpp>
  14. BOOST_HANA_NAMESPACE_BEGIN
  15. //! @cond
  16. template <typename Xs>
  17. constexpr auto is_empty_t::operator()(Xs const& xs) const {
  18. using It = typename hana::tag_of<Xs>::type;
  19. using IsEmpty = BOOST_HANA_DISPATCH_IF(is_empty_impl<It>,
  20. hana::Iterable<It>::value
  21. );
  22. #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
  23. static_assert(hana::Iterable<It>::value,
  24. "hana::is_empty(xs) requires 'xs' to be an Iterable");
  25. #endif
  26. return IsEmpty::apply(xs);
  27. }
  28. //! @endcond
  29. template <typename It, bool condition>
  30. struct is_empty_impl<It, when<condition>> : default_ {
  31. template <typename ...Args>
  32. static constexpr auto apply(Args&& ...) = delete;
  33. };
  34. BOOST_HANA_NAMESPACE_END
  35. #endif // !BOOST_HANA_IS_EMPTY_HPP