apply_to_value_type.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/apply_to_value_type.hpp
  9. /// \brief Similar to mpl::apply but for tagged types.
  10. #ifndef BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP
  11. #define BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_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/mpl/apply.hpp>
  18. /** \struct boost::bimaps::tags::support::apply_to_value_type
  19. \brief Higger order metafunction similar to mpl::apply but for tagged types.
  20. \code
  21. template< class Metafunction, class TaggedType >
  22. struct apply_to_value_type
  23. {
  24. typedef tagged
  25. <
  26. Metafuntion< value_type_of< TaggedType >::type >::type,
  27. tag_of< TaggedType >::type
  28. > type;
  29. };
  30. \endcode
  31. This higher order metafunctions is very useful, and it can be used with lambda
  32. expresions.
  33. See also tagged.
  34. **/
  35. #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  36. namespace boost {
  37. namespace bimaps {
  38. namespace tags {
  39. namespace support {
  40. template < class F, class TaggedType >
  41. struct apply_to_value_type;
  42. template < class F, class ValueType, class Tag >
  43. struct apply_to_value_type<F, tagged<ValueType,Tag> >
  44. {
  45. typedef BOOST_DEDUCED_TYPENAME mpl::apply< F, ValueType >::type new_value_type;
  46. typedef tagged< new_value_type, Tag > type;
  47. };
  48. } // namespace support
  49. } // namespace tags
  50. } // namespace bimaps
  51. } // namespace boost
  52. #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  53. #endif // BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP