value_type_of.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/value_type_of.hpp
  9. /// \brief Consistent way to access the value type of a tagged or untagged type.
  10. #ifndef BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP
  11. #define BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_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. /** \struct boost::bimaps::tags::support::value_type_of
  18. \brief Metafunction to work with tagged and untagged type uniformly
  19. \code
  20. template< class Type >
  21. struct value_type_of
  22. {
  23. typedef {UntaggedType} type;
  24. };
  25. \endcode
  26. If the type is tagged this metafunction returns Type::value_type, and if it is not
  27. tagged it return the same type. This allows to work consistenly with tagged and
  28. untagged types.
  29. See also tagged, tag_of.
  30. **/
  31. #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  32. namespace boost {
  33. namespace bimaps {
  34. namespace tags {
  35. namespace support {
  36. // value_type_of metafunction
  37. template< class Type >
  38. struct value_type_of
  39. {
  40. typedef Type type;
  41. };
  42. template< class Type, class Tag >
  43. struct value_type_of< tagged< Type, Tag > >
  44. {
  45. typedef Type type;
  46. };
  47. } // namespace support
  48. } // namespace tags
  49. } // namespace bimaps
  50. } // namespace boost
  51. #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  52. #endif // BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP