flyweight_fwd.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* Copyright 2006-2008 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)&&(_MSC_VER>=1200)
  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/parameter/parameters.hpp>
  16. #include <boost/preprocessor/punctuation/comma.hpp>
  17. #include <iosfwd>
  18. namespace boost{
  19. namespace flyweights{
  20. template<
  21. typename T,
  22. typename Arg1=parameter::void_,
  23. typename Arg2=parameter::void_,
  24. typename Arg3=parameter::void_,
  25. typename Arg4=parameter::void_,
  26. typename Arg5=parameter::void_
  27. >
  28. class flyweight;
  29. #define BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(n) \
  30. typename Arg##n##1,typename Arg##n##2,typename Arg##n##3, \
  31. typename Arg##n##4,typename Arg##n##5
  32. #define BOOST_FLYWEIGHT_TEMPL_ARGS(n) \
  33. Arg##n##1,Arg##n##2,Arg##n##3,Arg##n##4,Arg##n##5
  34. template<
  35. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  36. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  37. >
  38. bool operator==(
  39. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
  40. const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  41. template<
  42. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  43. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  44. >
  45. bool operator<(
  46. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
  47. const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  48. #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  49. template<
  50. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  51. typename T2
  52. >
  53. bool operator==(
  54. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
  55. template<
  56. typename T1,
  57. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  58. >
  59. bool operator==(
  60. const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  61. template<
  62. typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
  63. typename T2
  64. >
  65. bool operator<(
  66. const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
  67. template<
  68. typename T1,
  69. typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
  70. >
  71. bool operator<(
  72. const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
  73. #endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
  74. #define BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(t,a1,a2) \
  75. template<t> \
  76. inline bool operator!=(const a1& x,const a2& y); \
  77. \
  78. template<t> \
  79. inline bool operator>(const a1& x,const a2& y); \
  80. \
  81. template<t> \
  82. inline bool operator>=(const a1& x,const a2& y); \
  83. \
  84. template<t> \
  85. inline bool operator<=(const a1& x,const a2& y); \
  86. BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
  87. typename T1 BOOST_PP_COMMA()
  88. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
  89. typename T2 BOOST_PP_COMMA()
  90. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
  91. flyweight<
  92. T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
  93. >,
  94. flyweight<
  95. T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
  96. >)
  97. #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
  98. BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
  99. typename T1 BOOST_PP_COMMA()
  100. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1) BOOST_PP_COMMA()
  101. typename T2,
  102. flyweight<
  103. T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
  104. >,
  105. T2)
  106. BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(
  107. typename T1 BOOST_PP_COMMA()
  108. typename T2 BOOST_PP_COMMA()
  109. BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2),
  110. T1,
  111. flyweight<
  112. T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
  113. >)
  114. #endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
  115. template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
  116. inline void swap(
  117. flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x,
  118. flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& y);
  119. template<
  120. BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
  121. BOOST_TEMPLATED_STREAM_COMMA
  122. typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
  123. >
  124. inline BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& operator<<(
  125. BOOST_TEMPLATED_STREAM(ostream,ElemType,Traits)& out,
  126. const flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
  127. template<
  128. BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
  129. BOOST_TEMPLATED_STREAM_COMMA
  130. typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
  131. >
  132. inline BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& operator>>(
  133. BOOST_TEMPLATED_STREAM(istream,ElemType,Traits)& in,
  134. flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x);
  135. } /* namespace flyweights */
  136. using flyweights::flyweight;
  137. } /* namespace boost */
  138. #undef BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL
  139. #undef BOOST_FLYWEIGHT_TEMPL_ARGS
  140. #undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS
  141. #endif