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)
6 * See http://www.boost.org/libs/flyweight for library home page.
9 #ifndef BOOST_FLYWEIGHT_FLYWEIGHT_FWD_HPP
10 #define BOOST_FLYWEIGHT_FLYWEIGHT_FWD_HPP
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>
22 #if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
23 #include <boost/functional/hash_fwd.hpp>
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_
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
48 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
49 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
52 const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
53 const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
56 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
57 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
60 const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
61 const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
63 #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
65 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
69 const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
73 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
76 const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
79 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
83 const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
87 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
90 const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
91 #endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
93 #define BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL(t,a1,a2) \
95 inline bool operator!=(const a1& x,const a2& y); \
98 inline bool operator>(const a1& x,const a2& y); \
101 inline bool operator>=(const a1& x,const a2& y); \
104 inline bool operator<=(const a1& x,const a2& y); \
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),
112 T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
115 T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
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()
124 T1 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(1)
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),
134 T2 BOOST_PP_COMMA() BOOST_FLYWEIGHT_TEMPL_ARGS(2)
136 #endif /* !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) */
138 template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
140 flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x,
141 flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& y);
144 BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
145 BOOST_TEMPLATED_STREAM_COMMA
146 typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
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);
153 BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
154 BOOST_TEMPLATED_STREAM_COMMA
155 typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
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);
161 } /* namespace flyweights */
163 using flyweights::flyweight;
165 } /* namespace boost */
167 #if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
168 #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
170 #if !defined(_LIBCPP_VERSION)
172 template <class T> struct hash;
175 /* As discussed in http://lists.boost.org/Archives/boost/2011/02/177218.php */
176 #include <functional>
181 template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
182 struct hash<boost::flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)> >;
184 } /* namespace std */
185 #endif /* !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) */
188 #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
189 namespace flyweights{
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);
196 #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
197 } /* namespace flyweights */
199 } /* namespace boost */
200 #endif /* !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT) */
202 #undef BOOST_FLYWEIGHT_COMPLETE_COMP_OPS_DECL
203 #undef BOOST_FLYWEIGHT_TEMPL_ARGS
204 #undef BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS