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