tag_of.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /// \file tags/support/tag_of.hpp
  9. /// \brief Safe way to acces the tag of a type
  10. #ifndef BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP
  11. #define BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. #include <boost/bimap/tags/tagged.hpp>
  17. #include <boost/bimap/detail/debug/static_error.hpp>
  18. /** \struct boost::bimaps::tags::support::tag_of
  19. \brief Metafunction to obtain the tag of a type.
  20. \code
  21. template< class TaggedType >
  22. struct tag_of
  23. {
  24. typedef {Tag} type;
  25. };
  26. \endcode
  27. If the type is not tagged you will get a compile timer error with the following message:
  28. \verbatim
  29. USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, TaggedType
  30. \endverbatim
  31. See also tagged, value_type_of.
  32. **/
  33. #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  34. namespace boost {
  35. namespace bimaps {
  36. namespace tags {
  37. namespace support {
  38. // tag_of metafunction
  39. template< class Type >
  40. struct tag_of
  41. {
  42. BOOST_BIMAP_STATIC_ERROR( USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, (Type) );
  43. };
  44. template< class Type, class Tag >
  45. struct tag_of< tagged< Type, Tag > >
  46. {
  47. typedef Tag type;
  48. };
  49. } // namespace support
  50. } // namespace tags
  51. } // namespace bimaps
  52. } // namespace boost
  53. #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  54. #endif // BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP