| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::is_empty`. |
| 4 | |
| 5 | Copyright Louis Dionne 2013-2022 |
| 6 | Distributed under the Boost Software License, Version 1.0. |
| 7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) |
| 8 | */ |
| 9 | |
| 10 | #ifndef BOOST_HANA_FWD_IS_EMPTY_HPP |
| 11 | #define BOOST_HANA_FWD_IS_EMPTY_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/core/when.hpp> |
| 15 | |
| 16 | |
| 17 | namespace boost { namespace hana { |
| 18 | //! Returns whether the iterable is empty. |
| 19 | //! @ingroup group-Iterable |
| 20 | //! |
| 21 | //! Given an `Iterable` `xs`, `is_empty` returns whether `xs` contains |
| 22 | //! no more elements. In other words, it returns whether trying to |
| 23 | //! extract the tail of `xs` would be an error. In the current version |
| 24 | //! of the library, `is_empty` must return an `IntegralConstant` holding |
| 25 | //! a value convertible to `bool`. This is because only compile-time |
| 26 | //! `Iterable`s are supported right now. |
| 27 | //! |
| 28 | //! |
| 29 | //! Example |
| 30 | //! ------- |
| 31 | //! @include example/is_empty.cpp |
| 32 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 33 | constexpr auto is_empty = [](auto const& xs) { |
| 34 | return tag-dispatched; |
| 35 | }; |
| 36 | #else |
| 37 | template <typename It, typename = void> |
| 38 | struct is_empty_impl : is_empty_impl<It, when<true>> { }; |
| 39 | |
| 40 | struct is_empty_t { |
| 41 | template <typename Xs> |
| 42 | constexpr auto operator()(Xs const& xs) const; |
| 43 | }; |
| 44 | |
| 45 | BOOST_HANA_INLINE_VARIABLE constexpr is_empty_t is_empty{}; |
| 46 | #endif |
| 47 | }} // end namespace boost::hana |
| 48 | |
| 49 | #endif // !BOOST_HANA_FWD_IS_EMPTY_HPP |
| 50 | |