is_a.hpp 1.8 KB

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