1 | // Boost.Bimap |
2 | // |
3 | // Copyright (c) 2006-2007 Matias Capeletto |
4 | // |
5 | // Distributed under the Boost Software License, Version 1.0. |
6 | // (See accompanying file LICENSE_1_0.txt or copy at |
7 | // http://www.boost.org/LICENSE_1_0.txt) |
8 | |
9 | /// \file tags/support/tag_of.hpp |
10 | /// \brief Safe way to access the tag of a type |
11 | |
12 | #ifndef BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP |
13 | #define BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP |
14 | |
15 | #if defined(_MSC_VER) |
16 | #pragma once |
17 | #endif |
18 | |
19 | #include <boost/config.hpp> |
20 | |
21 | #include <boost/bimap/tags/tagged.hpp> |
22 | #include <boost/bimap/detail/debug/static_error.hpp> |
23 | |
24 | /** \struct boost::bimaps::tags::support::tag_of |
25 | \brief Metafunction to obtain the tag of a type. |
26 | |
27 | \code |
28 | template< class TaggedType > |
29 | struct tag_of |
30 | { |
31 | typedef {Tag} type; |
32 | }; |
33 | \endcode |
34 | |
35 | If the type is not tagged you will get a compile timer error with the following message: |
36 | |
37 | \verbatim |
38 | USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, TaggedType |
39 | \endverbatim |
40 | |
41 | See also tagged, value_type_of. |
42 | **/ |
43 | |
44 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES |
45 | |
46 | namespace boost { |
47 | namespace bimaps { |
48 | namespace tags { |
49 | namespace support { |
50 | |
51 | |
52 | // tag_of metafunction |
53 | |
54 | template< class Type > |
55 | struct tag_of |
56 | { |
57 | BOOST_BIMAP_STATIC_ERROR( USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, (Type) ); |
58 | }; |
59 | |
60 | template< class Type, class Tag > |
61 | struct tag_of< tagged< Type, Tag > > |
62 | { |
63 | typedef Tag type; |
64 | }; |
65 | |
66 | |
67 | } // namespace support |
68 | } // namespace tags |
69 | } // namespace bimaps |
70 | } // namespace boost |
71 | |
72 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES |
73 | |
74 | #endif // BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP |
75 | |
76 | |