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