is_a.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*!
  2. @file
  3. Defines `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_CORE_IS_A_HPP
  9. #define BOOST_HANA_CORE_IS_A_HPP
  10. #include <boost/hana/fwd/core/is_a.hpp>
  11. #include <boost/hana/bool.hpp>
  12. #include <boost/hana/config.hpp>
  13. #include <boost/hana/core/tag_of.hpp>
  14. #include <type_traits>
  15. BOOST_HANA_NAMESPACE_BEGIN
  16. //////////////////////////////////////////////////////////////////////////
  17. // is_a
  18. //////////////////////////////////////////////////////////////////////////
  19. template <typename DataType, typename T>
  20. struct is_a_t<DataType, T>
  21. : integral_constant<bool,
  22. std::is_same<DataType, typename hana::tag_of<T>::type>::value
  23. >
  24. { };
  25. template <typename DataType>
  26. struct is_a_t<DataType> {
  27. template <typename T>
  28. constexpr auto operator()(T const&) const
  29. { return hana::is_a<DataType, T>; }
  30. };
  31. BOOST_HANA_NAMESPACE_END
  32. #endif // !BOOST_HANA_CORE_IS_A_HPP