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