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
28namespace boost{
29
30namespace flyweights{
31
32template<
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>
40class flyweight;
41
42#define BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(n) \
43typename Arg##n##1,typename Arg##n##2,typename Arg##n##3, \
44typename Arg##n##4,typename Arg##n##5
45#define BOOST_FLYWEIGHT_TEMPL_ARGS(n) \
46Arg##n##1,Arg##n##2,Arg##n##3,Arg##n##4,Arg##n##5
47
48template<
49 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
50 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
51>
52bool operator==(
53 const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,
54 const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
55
56template<
57 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
58 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
59>
60bool 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)
65template<
66 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
67 typename T2
68>
69bool operator==(
70 const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
71
72template<
73 typename T1,
74 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
75>
76bool operator==(
77 const T1& x,const flyweight<T2,BOOST_FLYWEIGHT_TEMPL_ARGS(2)>& y);
78
79template<
80 typename T1,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(1),
81 typename T2
82>
83bool operator<(
84 const flyweight<T1,BOOST_FLYWEIGHT_TEMPL_ARGS(1)>& x,const T2& y);
85
86template<
87 typename T1,
88 typename T2,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(2)
89>
90bool 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) \
95template<t> \
96inline bool operator!=(const a1& x,const a2& y); \
97 \
98template<t> \
99inline bool operator>(const a1& x,const a2& y); \
100 \
101template<t> \
102inline bool operator>=(const a1& x,const a2& y); \
103 \
104template<t> \
105inline bool operator<=(const a1& x,const a2& y); \
106
107BOOST_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)
120BOOST_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
129BOOST_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
139template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
140inline void swap(
141 flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& x,
142 flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)>& y);
143
144template<
145 BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
146 BOOST_TEMPLATED_STREAM_COMMA
147 typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
148>
149inline 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
153template<
154 BOOST_TEMPLATED_STREAM_ARGS(ElemType,Traits)
155 BOOST_TEMPLATED_STREAM_COMMA
156 typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)
157>
158inline 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
164using 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)
179namespace std{
180template <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
187namespace std{
188
189template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
190BOOST_FLYWEIGHT_STD_HASH_STRUCT_KEYWORD
191hash<boost::flyweight<T,BOOST_FLYWEIGHT_TEMPL_ARGS(_)> >;
192
193} /* namespace std */
194#endif /* !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) */
195
196namespace boost{
197#if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
198namespace flyweights{
199#endif
200
201template<typename T,BOOST_FLYWEIGHT_TYPENAME_TEMPL_ARGS(_)>
202inline 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

source code of boost/libs/flyweight/include/boost/flyweight/flyweight_fwd.hpp