tag_of.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*!
  2. @file
  3. Defines `boost::hana::tag_of` and `boost::hana::tag_of_t`.
  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_TAG_OF_HPP
  9. #define BOOST_HANA_CORE_TAG_OF_HPP
  10. #include <boost/hana/fwd/core/tag_of.hpp>
  11. #include <boost/hana/config.hpp>
  12. #include <boost/hana/core/when.hpp>
  13. BOOST_HANA_NAMESPACE_BEGIN
  14. //! @cond
  15. template <typename T, typename>
  16. struct tag_of : tag_of<T, when<true>> { };
  17. //! @endcond
  18. namespace core_detail {
  19. template <typename ...>
  20. struct is_valid { static constexpr bool value = true; };
  21. }
  22. template <typename T, bool condition>
  23. struct tag_of<T, when<condition>> {
  24. using type = T;
  25. };
  26. template <typename T>
  27. struct tag_of<T, when<
  28. core_detail::is_valid<typename T::hana_tag>::value
  29. >> {
  30. using type = typename T::hana_tag;
  31. };
  32. template <typename T> struct tag_of<T const> : tag_of<T> { };
  33. template <typename T> struct tag_of<T volatile> : tag_of<T> { };
  34. template <typename T> struct tag_of<T const volatile> : tag_of<T> { };
  35. template <typename T> struct tag_of<T&> : tag_of<T> { };
  36. template <typename T> struct tag_of<T&&> : tag_of<T> { };
  37. BOOST_HANA_NAMESPACE_END
  38. #endif // !BOOST_HANA_CORE_TAG_OF_HPP