property_tags.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // (C) Copyright Tobias Schwinger
  2. //
  3. // Use modification and distribution are subject to the boost Software License,
  4. // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
  5. //------------------------------------------------------------------------------
  6. #ifndef BOOST_FT_DETAIL_TAGS_HPP_INCLUDED
  7. #define BOOST_FT_DETAIL_TAGS_HPP_INCLUDED
  8. #include <cstddef>
  9. #include <boost/type_traits/integral_constant.hpp>
  10. #include <boost/mpl/bitxor.hpp>
  11. namespace boost { namespace function_types {
  12. namespace detail
  13. {
  14. typedef long bits_t;
  15. template<bits_t Value> struct constant
  16. : boost::integral_constant<bits_t,Value>
  17. { };
  18. template<bits_t Bits, bits_t Mask> struct property_tag
  19. {
  20. typedef constant<Bits> bits;
  21. typedef constant<Mask> mask;
  22. };
  23. template<typename T> struct bits : T::bits { };
  24. template<typename T> struct mask : T::mask { };
  25. // forward declaration, defined in pp_tags
  26. template<bits_t Bits, bits_t CCID> struct encode_bits_impl;
  27. // forward declaration, defined in pp_tags
  28. template<bits_t LHS_bits, bits_t LHS_mask,
  29. bits_t RHS_bits, bits_t RHS_mask>
  30. struct tag_ice;
  31. // forward declaration, defined in retag_default_cc
  32. template<class Tag, class RegTag = Tag> struct retag_default_cc;
  33. template<bits_t Bits, bits_t CCID> struct encode_bits
  34. : constant<
  35. ::boost::function_types::detail::encode_bits_impl<Bits,CCID>::value
  36. >
  37. { };
  38. template<class LHS, class RHS> struct compound_tag
  39. {
  40. typedef constant<
  41. ::boost::function_types::detail::tag_ice
  42. < ::boost::function_types::detail::bits<LHS>::value
  43. , ::boost::function_types::detail::mask<LHS>::value
  44. , ::boost::function_types::detail::bits<RHS>::value
  45. , ::boost::function_types::detail::mask<RHS>::value
  46. >::combined_bits
  47. > bits;
  48. typedef constant<
  49. ::boost::function_types::detail::tag_ice
  50. < ::boost::function_types::detail::bits<LHS>::value
  51. , ::boost::function_types::detail::mask<LHS>::value
  52. , ::boost::function_types::detail::bits<RHS>::value
  53. , ::boost::function_types::detail::mask<RHS>::value
  54. >::combined_mask
  55. > mask;
  56. };
  57. template <class Base, class PropOld, class PropNew>
  58. struct changed_tag
  59. : Base
  60. {
  61. typedef mpl::bitxor_
  62. <typename Base::bits, typename PropOld::bits, typename PropNew::bits>
  63. bits;
  64. };
  65. template<class Tag, class QueryTag> struct represents_impl
  66. : boost::integral_constant<bool,
  67. ::boost::function_types::detail::tag_ice
  68. < ::boost::function_types::detail::bits<Tag>::value
  69. , ::boost::function_types::detail::mask<Tag>::value
  70. , ::boost::function_types::detail::bits<QueryTag>::value
  71. , ::boost::function_types::detail::mask<QueryTag>::value
  72. >::match
  73. >
  74. { };
  75. } // namespace detail
  76. typedef detail::property_tag<0,0> null_tag;
  77. template<class Tag1, class Tag2, class Tag3 = null_tag, class Tag4 = null_tag>
  78. struct tag
  79. : detail::compound_tag< detail::compound_tag<Tag1,Tag2>,
  80. detail::compound_tag<Tag3,Tag4> >
  81. { };
  82. template<class Tag1, class Tag2, class Tag3> struct tag<Tag1,Tag2,Tag3,null_tag>
  83. : detail::compound_tag<detail::compound_tag<Tag1,Tag2>,Tag3>
  84. { };
  85. template<class Tag1, class Tag2> struct tag<Tag1,Tag2,null_tag,null_tag>
  86. : detail::compound_tag<Tag1,Tag2>
  87. { };
  88. template<class Tag1> struct tag<Tag1,null_tag,null_tag,null_tag>
  89. : Tag1
  90. { };
  91. template<class Tag, class QueryTag> struct represents
  92. : detail::represents_impl<Tag, detail::retag_default_cc<QueryTag,Tag> >
  93. { };
  94. template<class Tag, class QueryTag> struct extract
  95. {
  96. typedef detail::constant<
  97. ::boost::function_types::detail::tag_ice
  98. < ::boost::function_types::detail::bits<Tag>::value
  99. , ::boost::function_types::detail::mask<Tag>::value
  100. , ::boost::function_types::detail::bits<QueryTag>::value
  101. , ::boost::function_types::detail::mask<QueryTag>::value
  102. >::extracted_bits
  103. > bits;
  104. typedef detail::constant<
  105. ::boost::function_types::detail::mask<QueryTag>::value
  106. > mask;
  107. };
  108. } } // namespace ::boost::function_types
  109. #include <boost/function_types/detail/pp_tags/preprocessed.hpp>
  110. namespace boost { namespace function_types {
  111. #define BOOST_FT_cc_file <boost/function_types/detail/pp_tags/cc_tag.hpp>
  112. #include <boost/function_types/detail/pp_loop.hpp>
  113. } } // namespace boost::function_types
  114. #endif