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