| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::is_a` and `boost::hana::is_an`. |
| 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_CORE_IS_A_HPP |
| 11 | #define BOOST_HANA_FWD_CORE_IS_A_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | |
| 15 | |
| 16 | namespace boost { namespace hana { |
| 17 | //! @ingroup group-core |
| 18 | //! Returns whether the tag of an object matches a given tag. |
| 19 | //! |
| 20 | //! Given a tag `Tag` and a C++ type `T`, `is_a<Tag, T>` is a compile-time |
| 21 | //! Logical representing whether the tag of `T` is exactly `Tag`. In other |
| 22 | //! words, it is equivalent to |
| 23 | //! @code |
| 24 | //! std::is_same<Tag, tag_of<T>::type> |
| 25 | //! @endcode |
| 26 | //! |
| 27 | //! For convenience, an alternate syntax is provided for using `is_a`. |
| 28 | //! Specifically, `is_a<Tag>` is a function object returning whether the |
| 29 | //! argument it is passed has the given tag. In other words, |
| 30 | //! @code |
| 31 | //! is_a<Tag>(x) == is_a<Tag, decltype(x)> |
| 32 | //! @endcode |
| 33 | //! |
| 34 | //! |
| 35 | //! Example |
| 36 | //! ------- |
| 37 | //! @include example/core/is_a.cpp |
| 38 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 39 | template <typename Tag, typename optional_T> |
| 40 | constexpr auto is_a = see-documentation; |
| 41 | #else |
| 42 | template <typename Tag, typename ...T> |
| 43 | struct is_a_t; |
| 44 | |
| 45 | template <typename Tag, typename ...T> |
| 46 | BOOST_HANA_INLINE_VARIABLE constexpr is_a_t<Tag, T...> is_a{}; |
| 47 | #endif |
| 48 | |
| 49 | //! @ingroup group-core |
| 50 | //! Equivalent to `is_a`; provided for consistency with the rules of the |
| 51 | //! English language. |
| 52 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 53 | template <typename Tag, typename ...T> |
| 54 | constexpr auto is_an = is_a<Tag, T...>; |
| 55 | #else |
| 56 | template <typename Tag, typename ...T> |
| 57 | BOOST_HANA_INLINE_VARIABLE constexpr is_a_t<Tag, T...> is_an{}; |
| 58 | #endif |
| 59 | }} // end namespace boost::hana |
| 60 | |
| 61 | #endif // !BOOST_HANA_FWD_CORE_IS_A_HPP |
| 62 | |