flyweight_fwd.hpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /* Copyright 2006-2015 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/flyweight for library home page.
  7. */
  8. #ifndef BOOST_FLYWEIGHT_FLYWEIGHT_FWD_HPP
  9. #define BOOST_FLYWEIGHT_FLYWEIGHT_FWD_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/detail/templated_streams.hpp>
  15. #include <boost/detail/workaround.hpp>
  16. #include <boost/parameter/parameters.hpp>
  17. #include <boost/preprocessor/punctuation/comma.hpp>
  18. #include <iosfwd>
  19. #if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
  20. #include <boost/functional/hash_fwd.hpp>
  21. #include <cstddef>
  22. #endif
  23. namespace boost{
  24. namespace flyweights{
  25. template<
  26. typename T,
  27. typename Arg1=parameter::void_,
  28. typename Arg2=parameter::void_,
  29. typename Arg3=parameter::void_,
  30. typename Arg4=parameter::void_,
  31. typename Arg5=parameter::void_
  32. >
  33. class flyweight;
  34. #define BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(n) \
  35. typename Arg##n##1,typename Arg##n##2,typename Arg##n##3, \
  36. typename Arg##n##4,typename Arg##n##5
  37. #define BOOST_FLYWEIGHT_TEMPL_ARGS(n) \
  38. Arg##n##1,Arg##n##2,Arg##n##3,Arg##n##4,Arg##n##5
  39. template<
  40. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  41. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  42. >
  43. bool operator==(
  44. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
  45. const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  46. template<
  47. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  48. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  49. >
  50. bool operator<(
  51. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
  52. const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  53. #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  54. template<
  55. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  56. typename T2
  57. >
  58. bool operator==(
  59. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
  60. template<
  61. typename T1,
  62. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  63. >
  64. bool operator==(
  65. const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  66. template<
  67. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  68. typename T2
  69. >
  70. bool operator<(
  71. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
  72. template<
  73. typename T1,
  74. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  75. >
  76. bool operator<(
  77. const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  78. #endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
  79. #define BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(t,a1,a2) \
  80. template<t> \
  81. inline bool operator!=(const a1& x,const a2& y); \
  82. \
  83. template<t> \
  84. inline bool operator>(const a1& x,const a2& y); \
  85. \
  86. template<t> \
  87. inline bool operator>=(const a1& x,const a2& y); \
  88. \
  89. template<t> \
  90. inline bool operator<=(const a1& x,const a2& y); \
  91. BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
  92. typename T1 BOOST_PP_COMMA()
  93. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
  94. typename T2 BOOST_PP_COMMA()
  95. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
  96. flyweight<
  97. T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
  98. >,
  99. flyweight<
  100. T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
  101. >)
  102. #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  103. BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
  104. typename T1 BOOST_PP_COMMA()
  105. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
  106. typename T2,
  107. flyweight<
  108. T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
  109. >,
  110. T2)
  111. BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
  112. typename T1 BOOST_PP_COMMA()
  113. typename T2 BOOST_PP_COMMA()
  114. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
  115. T1,
  116. flyweight<
  117. T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
  118. >)
  119. #endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
  120. template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
  121. inline void swap(
  122. flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x,
  123. flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& y);
  124. template<
  125. BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
  126. BOOST_TEMPLATED_STREAM_COMMA
  127. typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
  128. >
  129. inline BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& operator<<(
  130. BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& out,
  131. const flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
  132. template<
  133. BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
  134. BOOST_TEMPLATED_STREAM_COMMA
  135. typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
  136. >
  137. inline BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& operator>>(
  138. BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& in,
  139. flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
  140. } /* namespace flyweights */
  141. using flyweights::flyweight;
  142. } /* namespace boost */
  143. #if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
  144. #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
  145. #if BOOST_WORKAROUND(_CPPLIB_VER,==520)
  146. /* Dinkumware 5.20 defines std::hash as class rather than struct */
  147. #define BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD class
  148. #else
  149. #define BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD struct
  150. #endif
  151. #if !defined(_LIBCPP_VERSION)
  152. namespace std{
  153. template <class T> BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD hash;
  154. }
  155. #else
  156. /* As discussed in http://lists.boost.org/Archives/boost/2011/02/177218.php */
  157. #include <functional>
  158. #endif
  159. namespace std{
  160. template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
  161. BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD
  162. hash<boost::flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)> >;
  163. } /* namespace std */
  164. #endif /* !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) */
  165. namespace boost{
  166. #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
  167. namespace flyweights{
  168. #endif
  169. template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
  170. inline std::size_t hash_value(
  171. const flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
  172. #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
  173. } /* namespace flyweights */
  174. #endif
  175. } /* namespace boost */
  176. #endif /* !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT) */
  177. #undef BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL
  178. #undef BOOST_FLYWEIGHT_TEMPL_ARGS
  179. #undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS
  180. #endif