forked from boostorg/utility
Compare commits
52 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
e2308ce3c9 | |||
c733d07560 | |||
d497ff80e7 | |||
bb3fffd929 | |||
928091779d | |||
fc960ec5ef | |||
e76c779b8c | |||
1a4aa43cad | |||
9ece1d1d4c | |||
12de918a3a | |||
882d38c2c7 | |||
33041ad664 | |||
6a2aa822f8 | |||
09ab16bfc1 | |||
ec46e40809 | |||
b3a971e7e9 | |||
7ddb559887 | |||
ea8c99b1d5 | |||
56b0846099 | |||
42e0001370 | |||
cd8f85afee | |||
bddd52c4b9 | |||
8f03aeac4e | |||
3bb2568fad | |||
01e91a3799 | |||
55f3c351a3 | |||
3f72b10182 | |||
71cb8cb574 | |||
c950825ef4 | |||
66ca84a45d | |||
06404f7d39 | |||
2d860e2574 | |||
66514f61ff | |||
63cde4d3fd | |||
1950f292df | |||
92a0602190 | |||
c9a3ab1d04 | |||
0782034333 | |||
0808883f3c | |||
2f69501e55 | |||
5b83f641a8 | |||
c730ab4ffb | |||
e55610a0d0 | |||
bf968794c9 | |||
ce6e9c6698 | |||
7ac180ed54 | |||
271ea9e901 | |||
7cd572a326 | |||
90c56ba2ce | |||
a5439500f5 | |||
c0f0a4f51d | |||
7594e00460 |
199
Assignable.html
199
Assignable.html
@ -1,116 +1,109 @@
|
|||||||
<HTML>
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
<!--
|
|
||||||
-- Copyright (c) Jeremy Siek 2000
|
|
||||||
--
|
|
||||||
-- Permission to use, copy, modify, distribute and sell this software
|
|
||||||
-- and its documentation for any purpose is hereby granted without fee,
|
|
||||||
-- provided that the above copyright notice appears in all copies and
|
|
||||||
-- that both that copyright notice and this permission notice appear
|
|
||||||
-- in supporting documentation. Silicon Graphics makes no
|
|
||||||
-- representations about the suitability of this software for any
|
|
||||||
-- purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
-->
|
|
||||||
<Head>
|
|
||||||
<Title>Assignable</Title>
|
|
||||||
</HEAD>
|
|
||||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
|
||||||
ALINK="#ff0000">
|
|
||||||
<IMG SRC="../../boost.png"
|
|
||||||
ALT="C++ Boost" width="277" height="86">
|
|
||||||
<!--end header-->
|
|
||||||
<BR Clear>
|
|
||||||
<H1>Assignable</H1>
|
|
||||||
|
|
||||||
<h3>Description</h3>
|
<html>
|
||||||
A type is Assignable if it is possible to assign one object of the type
|
<head>
|
||||||
to another object of that type.
|
<meta http-equiv="Content-Language" content="en-us">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
||||||
|
|
||||||
|
<title>Assignable</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
<h3>Notation</h3>
|
<body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink=
|
||||||
<Table>
|
"#FF0000">
|
||||||
<TR>
|
<img src="../../boost.png" alt="C++ Boost" width="277" height=
|
||||||
<TD VAlign=top>
|
"86"><br clear="none">
|
||||||
<tt>T</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
is type that is a model of Assignable
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
<TR>
|
<h1>Assignable</h1>
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>t</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
is an object of type <tt>T</tt>
|
|
||||||
</TD>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<TR>
|
<h3>Description</h3>
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>u</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
is an object of type <tt>T</tt> or possibly <tt>const T</tt>
|
|
||||||
</TD>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
<p>A type is Assignable if it is possible to assign one object of the type
|
||||||
<h3>Definitions</h3>
|
to another object of that type.</p>
|
||||||
<h3>Valid expressions</h3>
|
|
||||||
<Table border>
|
|
||||||
<TR>
|
|
||||||
<TH>
|
|
||||||
Name
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Expression
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Return type
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Semantics
|
|
||||||
</TH>
|
|
||||||
</TR>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Assignment
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>t = u</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T&</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>t</tt> is equivalent to <tt>u</tt>
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
</table>
|
<h3>Notation</h3>
|
||||||
|
|
||||||
|
<table summary="">
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><tt>T</tt></td>
|
||||||
|
|
||||||
</table>
|
<td valign="top">is type that is a model of Assignable</td>
|
||||||
<h3>Models</h3>
|
</tr>
|
||||||
|
|
||||||
<UL>
|
<tr>
|
||||||
<LI><tt>int</tt>
|
<td valign="top"><tt>t</tt></td>
|
||||||
<LI><tt>std::pair</tt>
|
|
||||||
</UL>
|
|
||||||
|
|
||||||
<h3>See also</h3>
|
<td valign="top">is an object of type <tt>T</tt></td>
|
||||||
<a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</A>
|
</tr>
|
||||||
and
|
|
||||||
<A href="./CopyConstructible.html">CopyConstructible</A>
|
|
||||||
|
|
||||||
<br>
|
<tr>
|
||||||
<HR>
|
<td valign="top"><tt>u</tt></td>
|
||||||
<TABLE>
|
|
||||||
<TR valign=top>
|
|
||||||
<TD nowrap>Copyright © 2000</TD><TD>
|
|
||||||
<A HREF=http://www.lsc.nd.edu/~jsiek>Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
|
||||||
</TD></TR></TABLE>
|
|
||||||
|
|
||||||
</BODY>
|
<td valign="top">is an object of type <tt>T</tt> or possibly <tt>const
|
||||||
</HTML>
|
T</tt></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Definitions</h3>
|
||||||
|
|
||||||
|
<h3>Valid expressions</h3>
|
||||||
|
|
||||||
|
<table border summary="">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
<th>Expression</th>
|
||||||
|
|
||||||
|
<th>Return type</th>
|
||||||
|
|
||||||
|
<th>Semantics</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Assignment</td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>t = u</tt></td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>T&</tt></td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>t</tt> is equivalent to <tt>u</tt></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Models</h3>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><tt>int</tt></li>
|
||||||
|
|
||||||
|
<li><tt>std::pair</tt></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>See also</h3>
|
||||||
|
|
||||||
|
<p><a href=
|
||||||
|
"http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a>
|
||||||
|
and <a href="./CopyConstructible.html">CopyConstructible</a><br></p>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||||
|
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||||
|
height="31" width="88"></a></p>
|
||||||
|
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
|
||||||
|
|
||||||
|
<table summary="">
|
||||||
|
<tr valign="top">
|
||||||
|
<td nowrap><i>Copyright © 2000</i></td>
|
||||||
|
|
||||||
|
<td><i><a href="http://www.lsc.nd.edu/~jsiek">Jeremy Siek</a>, Univ.of
|
||||||
|
Notre Dame (<a href=
|
||||||
|
"mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>)</i></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p><i>Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
|
||||||
|
copy at <a href=
|
||||||
|
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
1036
Collection.html
1036
Collection.html
File diff suppressed because it is too large
Load Diff
@ -1,178 +1,139 @@
|
|||||||
<HTML>
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
<!--
|
|
||||||
-- Copyright (c) Jeremy Siek 2000
|
|
||||||
--
|
|
||||||
-- Permission to use, copy, modify, distribute and sell this software
|
|
||||||
-- and its documentation for any purpose is hereby granted without fee,
|
|
||||||
-- provided that the above copyright notice appears in all copies and
|
|
||||||
-- that both that copyright notice and this permission notice appear
|
|
||||||
-- in supporting documentation. Silicon Graphics makes no
|
|
||||||
-- representations about the suitability of this software for any
|
|
||||||
-- purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
-->
|
|
||||||
<Head>
|
|
||||||
<Title>Copy Constructible</Title>
|
|
||||||
</HEAD>
|
|
||||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
|
||||||
ALINK="#ff0000">
|
|
||||||
<IMG SRC="../../boost.png"
|
|
||||||
ALT="C++ Boost" width="277" height="86">
|
|
||||||
<!--end header-->
|
|
||||||
<BR Clear>
|
|
||||||
<H1>Copy Constructible</H1>
|
|
||||||
|
|
||||||
<h3>Description</h3>
|
<html>
|
||||||
A type is Copy Constructible if it is possible to copy objects of that
|
<head>
|
||||||
type.
|
<meta http-equiv="Content-Language" content="en-us">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
||||||
|
|
||||||
<h3>Notation</h3>
|
<title>Copy Constructible</title>
|
||||||
<Table>
|
</head>
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
is type that is a model of Copy Constructible
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
<TR>
|
<body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink=
|
||||||
<TD VAlign=top>
|
"#FF0000">
|
||||||
<tt>t</tt>
|
<img src="../../boost.png" alt="C++ Boost" width="277" height=
|
||||||
</TD>
|
"86"><br clear="none">
|
||||||
<TD VAlign=top>
|
|
||||||
is an object of type <tt>T</tt>
|
|
||||||
</TD>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<TR>
|
<h1>Copy Constructible</h1>
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>u</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
is an object of type <tt>const T</tt>
|
|
||||||
</TD>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
<h3>Description</h3>
|
||||||
<h3>Definitions</h3>
|
|
||||||
<h3>Valid expressions</h3>
|
|
||||||
<Table border>
|
|
||||||
<TR>
|
|
||||||
<TH>
|
|
||||||
Name
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Expression
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Return type
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Semantics
|
|
||||||
</TH>
|
|
||||||
</TR>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Copy constructor
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T(t)</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>t</tt> is equivalent to <tt>T(t)</tt>
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
|
<p>A type is Copy Constructible if it is possible to copy objects of that
|
||||||
|
type.</p>
|
||||||
|
|
||||||
<TR>
|
<h3>Notation</h3>
|
||||||
<TD VAlign=top>
|
|
||||||
Copy constructor
|
<table summary="">
|
||||||
</TD>
|
<tr>
|
||||||
<TD VAlign=top>
|
<td valign="top"><tt>T</tt></td>
|
||||||
<pre>
|
|
||||||
|
<td valign="top">is type that is a model of Copy Constructible</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><tt>t</tt></td>
|
||||||
|
|
||||||
|
<td valign="top">is an object of type <tt>T</tt></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><tt>u</tt></td>
|
||||||
|
|
||||||
|
<td valign="top">is an object of type <tt>const T</tt></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Definitions</h3>
|
||||||
|
|
||||||
|
<h3>Valid expressions</h3>
|
||||||
|
|
||||||
|
<table border summary="">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
<th>Expression</th>
|
||||||
|
|
||||||
|
<th>Return type</th>
|
||||||
|
|
||||||
|
<th>Semantics</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Copy constructor</td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>T(t)</tt></td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>T</tt></td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>t</tt> is equivalent to <tt>T(t)</tt></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Copy constructor</td>
|
||||||
|
|
||||||
|
<td valign="top">
|
||||||
|
<pre>
|
||||||
T(u)
|
T(u)
|
||||||
</pre>
|
</pre>
|
||||||
</TD>
|
</td>
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>u</tt> is equivalent to <tt>T(u)</tt>
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
|
<td valign="top"><tt>T</tt></td>
|
||||||
|
|
||||||
<TR>
|
<td valign="top"><tt>u</tt> is equivalent to <tt>T(u)</tt></td>
|
||||||
<TD VAlign=top>
|
</tr>
|
||||||
Destructor
|
|
||||||
</TD>
|
<tr>
|
||||||
<TD VAlign=top>
|
<td valign="top">Destructor</td>
|
||||||
<pre>
|
|
||||||
|
<td valign="top">
|
||||||
|
<pre>
|
||||||
t.~T()
|
t.~T()
|
||||||
</pre>
|
</pre>
|
||||||
</TD>
|
</td>
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
<TR>
|
<td valign="top"><tt>T</tt></td>
|
||||||
<TD VAlign=top>
|
|
||||||
Address Operator
|
<td valign="top"> </td>
|
||||||
</TD>
|
</tr>
|
||||||
<TD VAlign=top>
|
|
||||||
<pre>
|
<tr>
|
||||||
|
<td valign="top">Address Operator</td>
|
||||||
|
|
||||||
|
<td valign="top">
|
||||||
|
<pre>
|
||||||
&t
|
&t
|
||||||
</pre>
|
</pre>
|
||||||
</TD>
|
</td>
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T*</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
denotes the address of <tt>t</tt>
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
<TR>
|
<td valign="top"><tt>T*</tt></td>
|
||||||
<TD VAlign=top>
|
|
||||||
Address Operator
|
<td valign="top">denotes the address of <tt>t</tt></td>
|
||||||
</TD>
|
</tr>
|
||||||
<TD VAlign=top>
|
|
||||||
<pre>
|
<tr>
|
||||||
|
<td valign="top">Address Operator</td>
|
||||||
|
|
||||||
|
<td valign="top">
|
||||||
|
<pre>
|
||||||
&u
|
&u
|
||||||
</pre>
|
</pre>
|
||||||
</TD>
|
</td>
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>T*</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
denotes the address of <tt>u</tt>
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
|
|
||||||
|
<td valign="top"><tt>T*</tt></td>
|
||||||
|
|
||||||
|
<td valign="top">denotes the address of <tt>u</tt></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
</table>
|
<h3>Models</h3>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><tt>int</tt></li>
|
||||||
|
|
||||||
</table>
|
<li><tt>std::pair</tt></li>
|
||||||
<h3>Models</h3>
|
</ul>
|
||||||
|
|
||||||
<UL>
|
<h3>Concept Checking Class</h3>
|
||||||
<LI><tt>int</tt>
|
<pre>
|
||||||
<LI><tt>std::pair</tt>
|
|
||||||
</UL>
|
|
||||||
|
|
||||||
<h3>Concept Checking Class</h3>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct CopyConstructibleConcept
|
struct CopyConstructibleConcept
|
||||||
{
|
{
|
||||||
@ -192,19 +153,33 @@ denotes the address of <tt>u</tt>
|
|||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h3>See also</h3>
|
<h3>See also</h3>
|
||||||
<A
|
|
||||||
href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default Constructible</A>
|
|
||||||
and
|
|
||||||
<A hrefa="./Assignable.html">Assignable</A>
|
|
||||||
|
|
||||||
<br>
|
<p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default
|
||||||
<HR>
|
Constructible</a> and <a href="./Assignable.html">Assignable</a><br></p>
|
||||||
<TABLE>
|
<hr>
|
||||||
<TR valign=top>
|
|
||||||
<TD nowrap>Copyright © 2000</TD><TD>
|
|
||||||
<A HREF=http://www.lsc.nd.edu/~jsiek>Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
|
||||||
</TD></TR></TABLE>
|
|
||||||
|
|
||||||
</BODY>
|
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||||
</HTML>
|
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||||
|
height="31" width="88"></a></p>
|
||||||
|
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
|
||||||
|
December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
|
||||||
|
|
||||||
|
<table summary="">
|
||||||
|
<tr valign="top">
|
||||||
|
<td nowrap><i>Copyright © 2000</i></td>
|
||||||
|
|
||||||
|
<td><i><a href="http://www.lsc.nd.edu/~jsiek">Jeremy Siek</a>, Univ.of
|
||||||
|
Notre Dame (<a href=
|
||||||
|
"mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>)</i></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p><i>Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
|
||||||
|
copy at <a href=
|
||||||
|
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
@ -1,212 +1,210 @@
|
|||||||
<HTML>
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<html>
|
||||||
<!--
|
<!--
|
||||||
-- Copyright (c) Jeremy Siek 2000
|
== Copyright (c) 1996-1999
|
||||||
--
|
== Silicon Graphics Computer Systems, Inc.
|
||||||
-- Permission to use, copy, modify, distribute and sell this software
|
==
|
||||||
-- and its documentation for any purpose is hereby granted without fee,
|
== Permission to use, copy, modify, distribute and sell this software
|
||||||
-- provided that the above copyright notice appears in all copies and
|
== and its documentation for any purpose is hereby granted without fee,
|
||||||
-- that both that copyright notice and this permission notice appear
|
== provided that the above copyright notice appears in all copies and
|
||||||
-- in supporting documentation. Silicon Graphics makes no
|
== that both that copyright notice and this permission notice appear
|
||||||
-- representations about the suitability of this software for any
|
== in supporting documentation. Silicon Graphics makes no
|
||||||
-- purpose. It is provided "as is" without express or implied warranty.
|
== representations about the suitability of this software for any
|
||||||
|
== purpose. It is provided "as is" without express or implied warranty.
|
||||||
|
==
|
||||||
|
== Copyright (c) 1994
|
||||||
|
== Hewlett-Packard Company
|
||||||
|
==
|
||||||
|
== Permission to use, copy, modify, distribute and sell this software
|
||||||
|
== and its documentation for any purpose is hereby granted without fee,
|
||||||
|
== provided that the above copyright notice appears in all copies and
|
||||||
|
== that both that copyright notice and this permission notice appear
|
||||||
|
== in supporting documentation. Hewlett-Packard Company makes no
|
||||||
|
== representations about the suitability of this software for any
|
||||||
|
== purpose. It is provided "as is" without express or implied warranty.
|
||||||
|
==
|
||||||
-->
|
-->
|
||||||
<!--
|
|
||||||
-- Copyright (c) 1996-1999
|
|
||||||
-- Silicon Graphics Computer Systems, Inc.
|
|
||||||
--
|
|
||||||
-- Permission to use, copy, modify, distribute and sell this software
|
|
||||||
-- and its documentation for any purpose is hereby granted without fee,
|
|
||||||
-- provided that the above copyright notice appears in all copies and
|
|
||||||
-- that both that copyright notice and this permission notice appear
|
|
||||||
-- in supporting documentation. Silicon Graphics makes no
|
|
||||||
-- representations about the suitability of this software for any
|
|
||||||
-- purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
--
|
|
||||||
-- Copyright (c) 1994
|
|
||||||
-- Hewlett-Packard Company
|
|
||||||
--
|
|
||||||
-- Permission to use, copy, modify, distribute and sell this software
|
|
||||||
-- and its documentation for any purpose is hereby granted without fee,
|
|
||||||
-- provided that the above copyright notice appears in all copies and
|
|
||||||
-- that both that copyright notice and this permission notice appear
|
|
||||||
-- in supporting documentation. Hewlett-Packard Company makes no
|
|
||||||
-- representations about the suitability of this software for any
|
|
||||||
-- purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
--
|
|
||||||
-->
|
|
||||||
<Head>
|
|
||||||
<Title>LessThanComparable</Title>
|
|
||||||
</Head>
|
|
||||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
|
||||||
ALINK="#ff0000">
|
|
||||||
<IMG SRC="../../boost.png"
|
|
||||||
ALT="C++ Boost" width="277" height="86">
|
|
||||||
<!--end header-->
|
|
||||||
<BR Clear>
|
|
||||||
<H1>LessThanComparable</H1>
|
|
||||||
|
|
||||||
<h3>Description</h3>
|
<head>
|
||||||
A type is LessThanComparable if it is ordered: it must
|
<meta http-equiv="Content-Language" content="en-us">
|
||||||
be possible to compare two objects of that type using <tt>operator<</tt>, and
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
||||||
<tt>operator<</tt> must be a strict weak ordering relation.
|
|
||||||
|
|
||||||
|
<title>LessThanComparable</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
<h3>Refinement of</h3>
|
<body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink=
|
||||||
<h3>Associated types</h3>
|
"#FF0000">
|
||||||
<h3>Notation</h3>
|
<img src="../../boost.png" alt="C++ Boost" width="277" height=
|
||||||
<Table>
|
"86"><br clear="none">
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>X</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
A type that is a model of LessThanComparable
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>x</tt>, <tt>y</tt>, <tt>z</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Object of type <tt>X</tt>
|
|
||||||
</TD>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Definitions</h3>
|
|
||||||
Consider the relation <tt>!(x < y) && !(y < x)</tt>. If this relation is
|
|
||||||
transitive (that is, if <tt>!(x < y) && !(y < x) && !(y < z) && !(z < y)</tt>
|
|
||||||
implies <tt>!(x < z) && !(z < x)</tt>), then it satisfies the mathematical
|
|
||||||
definition of an equivalence relation. In this case, <tt>operator<</tt>
|
|
||||||
is a <i>strict weak ordering</i>.
|
|
||||||
<P>
|
|
||||||
If <tt>operator<</tt> is a strict weak ordering, and if each equivalence class
|
|
||||||
has only a single element, then <tt>operator<</tt> is a <i>total ordering</i>.
|
|
||||||
<h3>Valid expressions</h3>
|
|
||||||
<Table border>
|
|
||||||
<TR>
|
|
||||||
<TH>
|
|
||||||
Name
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Expression
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Type requirements
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Return type
|
|
||||||
</TH>
|
|
||||||
</TR>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Less
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>x < y</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Convertible to <tt>bool</tt>
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
<h1>LessThanComparable</h1>
|
||||||
|
|
||||||
|
<h3>Description</h3>
|
||||||
|
|
||||||
<h3>Expression semantics</h3>
|
<p>A type is LessThanComparable if it is ordered: it must be possible to
|
||||||
<Table border>
|
compare two objects of that type using <tt>operator<</tt>, and
|
||||||
<TR>
|
<tt>operator<</tt> must be a strict weak ordering relation.</p>
|
||||||
<TH>
|
|
||||||
Name
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Expression
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Precondition
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Semantics
|
|
||||||
</TH>
|
|
||||||
<TH>
|
|
||||||
Postcondition
|
|
||||||
</TH>
|
|
||||||
</TR>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Less
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>x < y</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>x</tt> and <tt>y</tt> are in the domain of <tt><</tt>
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
|
|
||||||
</TD>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
<h3>Refinement of</h3>
|
||||||
|
|
||||||
<h3>Complexity guarantees</h3>
|
<h3>Associated types</h3>
|
||||||
<h3>Invariants</h3>
|
|
||||||
<Table border>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Irreflexivity
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>x < x</tt> must be false.
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Antisymmetry
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>x < y</tt> implies !(y < x) <A href="#2">[2]</A>
|
|
||||||
</TD>
|
|
||||||
</TR>
|
|
||||||
<TR>
|
|
||||||
<TD VAlign=top>
|
|
||||||
Transitivity
|
|
||||||
</TD>
|
|
||||||
<TD VAlign=top>
|
|
||||||
<tt>x < y</tt> and <tt>y < z</tt> implies <tt>x < z</tt> <A href="#3">[3]</A>
|
|
||||||
</TD>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Models</h3>
|
|
||||||
<UL>
|
|
||||||
<LI>
|
|
||||||
int
|
|
||||||
</UL>
|
|
||||||
<h3>Notes</h3>
|
|
||||||
<P><A name="1">[1]</A>
|
|
||||||
Only <tt>operator<</tt> is fundamental; the other inequality operators
|
|
||||||
are essentially syntactic sugar.
|
|
||||||
<P><A name="2">[2]</A>
|
|
||||||
Antisymmetry is a theorem, not an axiom: it follows from
|
|
||||||
irreflexivity and transitivity.
|
|
||||||
<P><A name="3">[3]</A>
|
|
||||||
Because of irreflexivity and transitivity, <tt>operator<</tt> always
|
|
||||||
satisfies the definition of a <i>partial ordering</i>. The definition of
|
|
||||||
a <i>strict weak ordering</i> is stricter, and the definition of a
|
|
||||||
<i>total ordering</i> is stricter still.
|
|
||||||
<h3>See also</h3>
|
|
||||||
<A href="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</A>, <A href="http://www.sgi.com/tech/stl/StrictWeakOrdering.html">StrictWeakOrdering</A>
|
|
||||||
|
|
||||||
|
<h3>Notation</h3>
|
||||||
|
|
||||||
|
<table summary="">
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><tt>X</tt></td>
|
||||||
|
|
||||||
<br>
|
<td valign="top">A type that is a model of LessThanComparable</td>
|
||||||
<HR>
|
</tr>
|
||||||
<TABLE>
|
|
||||||
<TR valign=top>
|
|
||||||
<TD nowrap>Copyright © 2000</TD><TD>
|
|
||||||
<A HREF=http://www.lsc.nd.edu/~jsiek>Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
|
||||||
</TD></TR></TABLE>
|
|
||||||
|
|
||||||
</BODY>
|
<tr>
|
||||||
</HTML>
|
<td valign="top"><tt>x</tt>, <tt>y</tt>, <tt>z</tt></td>
|
||||||
|
|
||||||
|
<td valign="top">Object of type <tt>X</tt></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Definitions</h3>
|
||||||
|
|
||||||
|
<p>Consider the relation <tt>!(x < y) && !(y < x)</tt>. If
|
||||||
|
this relation is transitive (that is, if <tt>!(x < y) && !(y
|
||||||
|
< x) && !(y < z) && !(z < y)</tt> implies <tt>!(x
|
||||||
|
< z) && !(z < x)</tt>), then it satisfies the mathematical
|
||||||
|
definition of an equivalence relation. In this case, <tt>operator<</tt>
|
||||||
|
is a <i>strict weak ordering</i>.</p>
|
||||||
|
|
||||||
|
<p>If <tt>operator<</tt> is a strict weak ordering, and if each
|
||||||
|
equivalence class has only a single element, then <tt>operator<</tt> is
|
||||||
|
a <i>total ordering</i>.</p>
|
||||||
|
|
||||||
|
<h3>Valid expressions</h3>
|
||||||
|
|
||||||
|
<table border summary="">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
<th>Expression</th>
|
||||||
|
|
||||||
|
<th>Type requirements</th>
|
||||||
|
|
||||||
|
<th>Return type</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Less</td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>x < y</tt></td>
|
||||||
|
|
||||||
|
<td valign="top"> </td>
|
||||||
|
|
||||||
|
<td valign="top">Convertible to <tt>bool</tt></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Expression semantics</h3>
|
||||||
|
|
||||||
|
<table border summary="">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
|
||||||
|
<th>Expression</th>
|
||||||
|
|
||||||
|
<th>Precondition</th>
|
||||||
|
|
||||||
|
<th>Semantics</th>
|
||||||
|
|
||||||
|
<th>Postcondition</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Less</td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>x < y</tt></td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>x</tt> and <tt>y</tt> are in the domain of
|
||||||
|
<tt><</tt></td>
|
||||||
|
|
||||||
|
<td valign="top"> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Complexity guarantees</h3>
|
||||||
|
|
||||||
|
<h3>Invariants</h3>
|
||||||
|
|
||||||
|
<table border summary="">
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Irreflexivity</td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>x < x</tt> must be false.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Antisymmetry</td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>x < y</tt> implies !(y < x) <a href=
|
||||||
|
"#n2">[2]</a></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td valign="top">Transitivity</td>
|
||||||
|
|
||||||
|
<td valign="top"><tt>x < y</tt> and <tt>y < z</tt> implies <tt>x
|
||||||
|
< z</tt> <a href="#n3">[3]</a></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Models</h3>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>int</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Notes</h3>
|
||||||
|
|
||||||
|
<p><a name="n1" id="n1">[1]</a> Only <tt>operator<</tt> is fundamental;
|
||||||
|
the other inequality operators are essentially syntactic sugar.</p>
|
||||||
|
|
||||||
|
<p><a name="n2" id="n2">[2]</a> Antisymmetry is a theorem, not an axiom: it
|
||||||
|
follows from irreflexivity and transitivity.</p>
|
||||||
|
|
||||||
|
<p><a name="n3" id="n3">[3]</a> Because of irreflexivity and transitivity,
|
||||||
|
<tt>operator<</tt> always satisfies the definition of a <i>partial
|
||||||
|
ordering</i>. The definition of a <i>strict weak ordering</i> is stricter,
|
||||||
|
and the definition of a <i>total ordering</i> is stricter still.</p>
|
||||||
|
|
||||||
|
<h3>See also</h3>
|
||||||
|
|
||||||
|
<p><a href=
|
||||||
|
"http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</a>,
|
||||||
|
<a href=
|
||||||
|
"http://www.sgi.com/tech/stl/StrictWeakOrdering.html">StrictWeakOrdering</a><br>
|
||||||
|
</p>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||||
|
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||||
|
height="31" width="88"></a></p>
|
||||||
|
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
|
||||||
|
December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
|
||||||
|
|
||||||
|
<table summary="">
|
||||||
|
<tr valign="top">
|
||||||
|
<td nowrap><i>Copyright © 2000</i></td>
|
||||||
|
|
||||||
|
<td><i><a href="http://www.lsc.nd.edu/~jsiek">Jeremy Siek</a>, Univ.of
|
||||||
|
Notre Dame (<a href=
|
||||||
|
"mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>)</i></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p><i>Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
|
||||||
|
copy at <a href=
|
||||||
|
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
@ -1,92 +1,95 @@
|
|||||||
<HTML>
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
<!--
|
|
||||||
-- Copyright (c) Jeremy Siek 2000
|
|
||||||
--
|
|
||||||
-- Permission to use, copy, modify, distribute and sell this software
|
|
||||||
-- and its documentation for any purpose is hereby granted without fee,
|
|
||||||
-- provided that the above copyright notice appears in all copies and
|
|
||||||
-- that both that copyright notice and this permission notice appear
|
|
||||||
-- in supporting documentation. Silicon Graphics makes no
|
|
||||||
-- representations about the suitability of this software for any
|
|
||||||
-- purpose. It is provided "as is" without express or implied warranty.
|
|
||||||
-->
|
|
||||||
<Head>
|
|
||||||
<Title>MultiPassInputIterator</Title>
|
|
||||||
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
|
|
||||||
ALINK="#ff0000">
|
|
||||||
<IMG SRC="../../boost.png"
|
|
||||||
ALT="C++ Boost" width="277" height="86">
|
|
||||||
|
|
||||||
<BR Clear>
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Language" content="en-us">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
||||||
|
|
||||||
<H2>
|
<title>MultiPassInputIterator</title>
|
||||||
<A NAME="concept:MultiPassInputIterator"></A>
|
</head>
|
||||||
Multi-Pass Input Iterator
|
|
||||||
</H2>
|
|
||||||
|
|
||||||
This concept is a refinement of <a
|
<body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink=
|
||||||
href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
"#FF0000">
|
||||||
adding the requirements that the iterator can be used to make multiple
|
<img src="../../boost.png" alt="C++ Boost" width="277" height=
|
||||||
passes through a range, and that if <TT>it1 == it2</TT> and
|
"86"><br clear="none">
|
||||||
<TT>it1</TT> is dereferenceable then <TT>++it1 == ++it2</TT>. The
|
|
||||||
Multi-Pass Input Iterator is very similar to the <a
|
|
||||||
href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>. The
|
|
||||||
only difference is that a <a
|
|
||||||
href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>
|
|
||||||
requires the <TT>reference</TT> type to be <TT>value_type&</TT>, whereas
|
|
||||||
MultiPassInputIterator is like <a
|
|
||||||
href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>
|
|
||||||
in that the <TT>reference</TT> type merely has to be convertible to
|
|
||||||
<TT>value_type</TT>.
|
|
||||||
|
|
||||||
|
<h2><a name="concept:MultiPassInputIterator" id=
|
||||||
|
"concept:MultiPassInputIterator"></a> Multi-Pass Input Iterator</h2>
|
||||||
|
|
||||||
<h3>Design Notes</h3>
|
<p>This concept is a refinement of <a href=
|
||||||
|
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>, adding
|
||||||
|
the requirements that the iterator can be used to make multiple passes
|
||||||
|
through a range, and that if <tt>it1 == it2</tt> and <tt>it1</tt> is
|
||||||
|
dereferenceable then <tt>++it1 == ++it2</tt>. The Multi-Pass Input Iterator
|
||||||
|
is very similar to the <a href=
|
||||||
|
"http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>.
|
||||||
|
The only difference is that a <a href=
|
||||||
|
"http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>
|
||||||
|
requires the <tt>reference</tt> type to be <tt>value_type&</tt>,
|
||||||
|
whereas MultiPassInputIterator is like <a href=
|
||||||
|
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> in that
|
||||||
|
the <tt>reference</tt> type merely has to be convertible to
|
||||||
|
<tt>value_type</tt>.</p>
|
||||||
|
|
||||||
comments by Valentin Bonnard:
|
<h3>Design Notes</h3>
|
||||||
|
|
||||||
<p> I think that introducing Multi-Pass Input Iterator isn't the right
|
<p>comments by Valentin Bonnard:</p>
|
||||||
solution. Do you also want to define Multi-Pass Bidirectionnal Iterator
|
|
||||||
and Multi-Pass Random Access Iterator ? I don't, definitly. It only
|
|
||||||
confuses the issue. The problem lies into the existing hierarchy of
|
|
||||||
iterators, which mixes movabillity, modifiabillity and lvalue-ness,
|
|
||||||
and these are clearly independant.
|
|
||||||
|
|
||||||
<p> The terms Forward, Bidirectionnal and Random Access are about
|
<p>I think that introducing Multi-Pass Input Iterator isn't the right
|
||||||
movabillity and shouldn't be used to mean anything else. In a
|
solution. Do you also want to define Multi-Pass Bidirectionnal Iterator and
|
||||||
completly orthogonal way, iterators can be immutable, mutable, or
|
Multi-Pass Random Access Iterator ? I don't, definitly. It only confuses
|
||||||
neither. Lvalueness of iterators is also orthogonal with
|
the issue. The problem lies into the existing hierarchy of iterators, which
|
||||||
immutabillity. With these clean concepts, your Multi-Pass Input Iterator
|
mixes movabillity, modifiabillity and lvalue-ness, and these are clearly
|
||||||
is just called a Forward Iterator.
|
independant.</p>
|
||||||
|
|
||||||
<p>
|
<p>The terms Forward, Bidirectionnal and Random Access are about
|
||||||
Other translations are:<br>
|
movabillity and shouldn't be used to mean anything else. In a completly
|
||||||
std::Forward Iterator -> ForwardIterator & Lvalue Iterator<br>
|
orthogonal way, iterators can be immutable, mutable, or neither. Lvalueness
|
||||||
std::Bidirectionnal Iterator -> Bidirectionnal Iterator & Lvalue Iterator<br>
|
of iterators is also orthogonal with immutabillity. With these clean
|
||||||
std::Random Access Iterator -> Random Access Iterator & Lvalue Iterator<br>
|
concepts, your Multi-Pass Input Iterator is just called a Forward
|
||||||
|
Iterator.</p>
|
||||||
|
|
||||||
<p>
|
<p>Other translations are:<br>
|
||||||
Note that in practice the only operation not allowed on my
|
std::Forward Iterator -> ForwardIterator & Lvalue Iterator<br>
|
||||||
Forward Iterator which is allowed on std::Forward Iterator is
|
std::Bidirectionnal Iterator -> Bidirectionnal Iterator & Lvalue
|
||||||
<tt>&*it</tt>. I think that <tt>&*</tt> is rarely needed in generic code.
|
Iterator<br>
|
||||||
|
std::Random Access Iterator -> Random Access Iterator & Lvalue
|
||||||
|
Iterator<br></p>
|
||||||
|
|
||||||
<p>
|
<p>Note that in practice the only operation not allowed on my Forward
|
||||||
reply by Jeremy Siek:
|
Iterator which is allowed on std::Forward Iterator is <tt>&*it</tt>. I
|
||||||
|
think that <tt>&*</tt> is rarely needed in generic code.</p>
|
||||||
|
|
||||||
<p>
|
<p>reply by Jeremy Siek:</p>
|
||||||
The above analysis by Valentin is right on. Of course, there is
|
|
||||||
the problem with backward compatibility. The current STL implementations
|
|
||||||
are based on the old definition of Forward Iterator. The right course
|
|
||||||
of action is to get Forward Iterator, etc. changed in the C++ standard.
|
|
||||||
Once that is done we can drop Multi-Pass Input Iterator.
|
|
||||||
|
|
||||||
|
<p>The above analysis by Valentin is right on. Of course, there is the
|
||||||
|
problem with backward compatibility. The current STL implementations are
|
||||||
|
based on the old definition of Forward Iterator. The right course of action
|
||||||
|
is to get Forward Iterator, etc. changed in the C++ standard. Once that is
|
||||||
|
done we can drop Multi-Pass Input Iterator.<br></p>
|
||||||
|
<hr>
|
||||||
|
|
||||||
<br>
|
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||||
<HR>
|
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||||
<TABLE>
|
height="31" width="88"></a></p>
|
||||||
<TR valign=top>
|
|
||||||
<TD nowrap>Copyright © 2000</TD><TD>
|
|
||||||
<a HREF="../../people/jeremy_siek.htm">Jeremy Siek</a>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
|
||||||
</TD></TR></TABLE>
|
|
||||||
|
|
||||||
</BODY>
|
<p>Revised
|
||||||
</HTML>
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
|
||||||
|
December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
|
||||||
|
|
||||||
|
<table summary="">
|
||||||
|
<tr valign="top">
|
||||||
|
<td nowrap><i>Copyright © 2000</i></td>
|
||||||
|
|
||||||
|
<td><i><a href="http://www.lsc.nd.edu/~jsiek">Jeremy Siek</a>, Univ.of
|
||||||
|
Notre Dame (<a href=
|
||||||
|
"mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>)</i></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p><i>Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
|
||||||
|
copy at <a href=
|
||||||
|
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
@ -145,14 +145,20 @@ objects are is implemented in <a href="../../boost/utility/compare_pointees.hpp"
|
|||||||
so direct usage of relational operators with the implied aliasing of shallow semantics
|
so direct usage of relational operators with the implied aliasing of shallow semantics
|
||||||
-as with pointers- should not be used with generic code written for this concept.</p>
|
-as with pointers- should not be used with generic code written for this concept.</p>
|
||||||
|
|
||||||
|
<h3>Acknowledgements</h3>
|
||||||
|
<p>Based on the original concept developed by Augustus Saunders.
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
</p>
|
||||||
<HR>
|
<HR>
|
||||||
<TABLE>
|
<TABLE>
|
||||||
<TR valign=top>
|
<TR valign=top>
|
||||||
<TD nowrap>Copyright © 2003</TD><TD>
|
<TD nowrap>Copyright © 2003</TD><TD>
|
||||||
<A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>,
|
<A HREF="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</A>
|
||||||
based on the original concept developed by Augustus Saunders.
|
|
||||||
</TD></TR></TABLE>
|
</TD></TR></TABLE>
|
||||||
|
|
||||||
|
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||||
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
|
||||||
|
|
||||||
</BODY>
|
</BODY>
|
||||||
</HTML>
|
</HTML>
|
13
assert.html
13
assert.html
@ -47,10 +47,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil
|
|||||||
<P>As is the case with <STRONG><cassert></STRONG>, <STRONG><boost/assert.hpp></STRONG>
|
<P>As is the case with <STRONG><cassert></STRONG>, <STRONG><boost/assert.hpp></STRONG>
|
||||||
can be included multiple times in a single translation unit. <STRONG>BOOST_ASSERT</STRONG>
|
can be included multiple times in a single translation unit. <STRONG>BOOST_ASSERT</STRONG>
|
||||||
will be redefined each time as specified above.</P>
|
will be redefined each time as specified above.</P>
|
||||||
|
<p><STRONG><boost/assert.hpp></STRONG> also defines the macro <STRONG>BOOST_VERIFY</STRONG>.
|
||||||
|
It has exactly the same behavior as <STRONG>BOOST_ASSERT</STRONG>, except that
|
||||||
|
the expression that is passed to <STRONG>BOOST_VERIFY</STRONG> is always
|
||||||
|
evaluated. This is useful when the asserted expression has desirable side
|
||||||
|
effects; it can also help suppress warnings about unused variables when the
|
||||||
|
only use of the variable is inside an assertion.</p>
|
||||||
<p><br>
|
<p><br>
|
||||||
<small>Copyright <20> 2002 by Peter Dimov. Permission to copy, use, modify, sell and
|
<small>Copyright <20> 2002, 2007 by Peter Dimov. Distributed under the Boost Software
|
||||||
distribute this document is granted provided this copyright notice appears in
|
License, Version 1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
all copies. This document is provided "as is" without express or implied
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||||
warranty, and with no claim as to its suitability for any purpose.</small></p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -334,7 +334,7 @@ with the exact pointer type used in <code>switcher</code>'s constructor.</p>
|
|||||||
<h3><a name="contributors">Contributors</a></h3>
|
<h3><a name="contributors">Contributors</a></h3>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt><a href="../../people/ed_brey.htm">Ed Brey</a>
|
<dt><a href="http://www.boost.org/people/ed_brey.htm">Ed Brey</a>
|
||||||
<dd>Suggested some interface changes.
|
<dd>Suggested some interface changes.
|
||||||
|
|
||||||
<dt><a href="http://www.moocat.org">R. Samuel Klatchko</a> (<a
|
<dt><a href="http://www.moocat.org">R. Samuel Klatchko</a> (<a
|
||||||
@ -343,7 +343,7 @@ with the exact pointer type used in <code>switcher</code>'s constructor.</p>
|
|||||||
<dd>Invented the idiom of how to use a class member for initializing
|
<dd>Invented the idiom of how to use a class member for initializing
|
||||||
a base class.
|
a base class.
|
||||||
|
|
||||||
<dt><a href="../../people/dietmar_kuehl.htm">Dietmar Kuehl</a>
|
<dt><a href="http://www.boost.org/people/dietmar_kuehl.htm">Dietmar Kuehl</a>
|
||||||
<dd>Popularized the base-from-member idiom in his
|
<dd>Popularized the base-from-member idiom in his
|
||||||
<a href="http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/">IOStream
|
<a href="http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/">IOStream
|
||||||
example classes</a>.
|
example classes</a>.
|
||||||
@ -353,7 +353,7 @@ with the exact pointer type used in <code>switcher</code>'s constructor.</p>
|
|||||||
can be controlled and automated with macros. The implementation uses
|
can be controlled and automated with macros. The implementation uses
|
||||||
the <a href="../preprocessor/index.html">Preprocessor library</a>.
|
the <a href="../preprocessor/index.html">Preprocessor library</a>.
|
||||||
|
|
||||||
<dt><a href="../../people/daryle_walker.html">Daryle Walker</a>
|
<dt><a href="http://www.boost.org/people/daryle_walker.html">Daryle Walker</a>
|
||||||
<dd>Started the library. Contributed the test file <cite><a
|
<dd>Started the library. Contributed the test file <cite><a
|
||||||
href="base_from_member_test.cpp">base_from_member_test.cpp</a></cite>.
|
href="base_from_member_test.cpp">base_from_member_test.cpp</a></cite>.
|
||||||
</dl>
|
</dl>
|
||||||
|
@ -606,7 +606,7 @@ template <bool opt>
|
|||||||
struct filler
|
struct filler
|
||||||
{
|
{
|
||||||
template <typename I, typename T>
|
template <typename I, typename T>
|
||||||
static void do_fill(I first, I last, typename boost::call_traits<T>::param_type val);
|
static void do_fill(I first, I last, typename boost::call_traits<T>::param_type val)
|
||||||
{
|
{
|
||||||
while(first != last)
|
while(first != last)
|
||||||
{
|
{
|
||||||
@ -762,3 +762,4 @@ href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
// 03 Oct 2000:
|
// 03 Oct 2000:
|
||||||
// Enabled extra tests for VC6.
|
// Enabled extra tests for VC6.
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -22,40 +21,6 @@
|
|||||||
#include <libs/type_traits/test/test.hpp>
|
#include <libs/type_traits/test/test.hpp>
|
||||||
#include <libs/type_traits/test/check_type.hpp>
|
#include <libs/type_traits/test/check_type.hpp>
|
||||||
|
|
||||||
//
|
|
||||||
// define tests here
|
|
||||||
unsigned failures = 0;
|
|
||||||
unsigned test_count = 0;
|
|
||||||
//
|
|
||||||
// This must get defined within the test file.
|
|
||||||
// All compilers have bugs, set this to the number of
|
|
||||||
// regressions *expected* from a given compiler,
|
|
||||||
// if there are no workarounds for the bugs, *and*
|
|
||||||
// the regressions have been investigated.
|
|
||||||
//
|
|
||||||
extern unsigned int expected_failures;
|
|
||||||
//
|
|
||||||
// proc check_result()
|
|
||||||
// Checks that there were no regressions:
|
|
||||||
//
|
|
||||||
int check_result(int argc, char** argv)
|
|
||||||
{
|
|
||||||
std::cout << test_count << " tests completed, "
|
|
||||||
<< failures << " failures found, "
|
|
||||||
<< expected_failures << " failures expected from this compiler." << std::endl;
|
|
||||||
if((argc == 2)
|
|
||||||
&& (argv[1][0] == '-')
|
|
||||||
&& (argv[1][1] == 'a')
|
|
||||||
&& (argv[1][2] == 0))
|
|
||||||
{
|
|
||||||
std::cout << "Press any key to continue...";
|
|
||||||
std::cin.get();
|
|
||||||
}
|
|
||||||
return (failures == expected_failures)
|
|
||||||
? 0
|
|
||||||
: (failures != 0) ? static_cast<int>(failures) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// a way prevent warnings for unused variables
|
// a way prevent warnings for unused variables
|
||||||
template<class T> inline void unused_variable(const T&) {}
|
template<class T> inline void unused_variable(const T&) {}
|
||||||
|
|
||||||
@ -156,9 +121,9 @@ void call_traits_checker<T>::operator()(param_type p)
|
|||||||
T t(p);
|
T t(p);
|
||||||
contained<T> c(t);
|
contained<T> c(t);
|
||||||
cout << "checking contained<" << typeid(T).name() << ">..." << endl;
|
cout << "checking contained<" << typeid(T).name() << ">..." << endl;
|
||||||
assert(t == c.value());
|
BOOST_CHECK(t == c.value());
|
||||||
assert(t == c.get());
|
BOOST_CHECK(t == c.get());
|
||||||
assert(t == c.const_get());
|
BOOST_CHECK(t == c.const_get());
|
||||||
#ifndef __ICL
|
#ifndef __ICL
|
||||||
//cout << "typeof contained<" << typeid(T).name() << ">::v_ is: " << typeid(&contained<T>::v_).name() << endl;
|
//cout << "typeof contained<" << typeid(T).name() << ">::v_ is: " << typeid(&contained<T>::v_).name() << endl;
|
||||||
cout << "typeof contained<" << typeid(T).name() << ">::value() is: " << typeid(&contained<T>::value).name() << endl;
|
cout << "typeof contained<" << typeid(T).name() << ">::value() is: " << typeid(&contained<T>::value).name() << endl;
|
||||||
@ -180,11 +145,11 @@ struct call_traits_checker<T[N]>
|
|||||||
cout << "checking contained<" << typeid(T[N]).name() << ">..." << endl;
|
cout << "checking contained<" << typeid(T[N]).name() << ">..." << endl;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for(i = 0; i < N; ++i)
|
for(i = 0; i < N; ++i)
|
||||||
assert(t[i] == c.value()[i]);
|
BOOST_CHECK(t[i] == c.value()[i]);
|
||||||
for(i = 0; i < N; ++i)
|
for(i = 0; i < N; ++i)
|
||||||
assert(t[i] == c.get()[i]);
|
BOOST_CHECK(t[i] == c.get()[i]);
|
||||||
for(i = 0; i < N; ++i)
|
for(i = 0; i < N; ++i)
|
||||||
assert(t[i] == c.const_get()[i]);
|
BOOST_CHECK(t[i] == c.const_get()[i]);
|
||||||
|
|
||||||
cout << "typeof contained<" << typeid(T[N]).name() << ">::v_ is: " << typeid(&contained<T[N]>::v_).name() << endl;
|
cout << "typeof contained<" << typeid(T[N]).name() << ">::v_ is: " << typeid(&contained<T[N]>::v_).name() << endl;
|
||||||
cout << "typeof contained<" << typeid(T[N]).name() << ">::value is: " << typeid(&contained<T[N]>::value).name() << endl;
|
cout << "typeof contained<" << typeid(T[N]).name() << ">::value is: " << typeid(&contained<T[N]>::value).name() << endl;
|
||||||
@ -202,7 +167,7 @@ template <class W, class U>
|
|||||||
void check_wrap(const W& w, const U& u)
|
void check_wrap(const W& w, const U& u)
|
||||||
{
|
{
|
||||||
cout << "checking " << typeid(W).name() << "..." << endl;
|
cout << "checking " << typeid(W).name() << "..." << endl;
|
||||||
assert(w.value() == u);
|
BOOST_CHECK(w.value() == u);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -213,8 +178,8 @@ template <class T, class U, class V>
|
|||||||
void check_make_pair(T c, U u, V v)
|
void check_make_pair(T c, U u, V v)
|
||||||
{
|
{
|
||||||
cout << "checking std::pair<" << typeid(c.first).name() << ", " << typeid(c.second).name() << ">..." << endl;
|
cout << "checking std::pair<" << typeid(c.first).name() << ", " << typeid(c.second).name() << ">..." << endl;
|
||||||
assert(c.first == u);
|
BOOST_CHECK(c.first == u);
|
||||||
assert(c.second == v);
|
BOOST_CHECK(c.second == v);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,8 +255,6 @@ int main(int argc, char *argv[ ])
|
|||||||
BOOST_CHECK_TYPE(int&, boost::call_traits<cr_type>::param_type);
|
BOOST_CHECK_TYPE(int&, boost::call_traits<cr_type>::param_type);
|
||||||
#else
|
#else
|
||||||
std::cout << "Your compiler cannot instantiate call_traits<int&const>, skipping four tests (4 errors)" << std::endl;
|
std::cout << "Your compiler cannot instantiate call_traits<int&const>, skipping four tests (4 errors)" << std::endl;
|
||||||
failures += 4;
|
|
||||||
test_count += 4;
|
|
||||||
#endif
|
#endif
|
||||||
BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::value_type);
|
BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::value_type);
|
||||||
BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::reference);
|
BOOST_CHECK_TYPE(const int&, boost::call_traits<const int&>::reference);
|
||||||
@ -313,13 +276,9 @@ int main(int argc, char *argv[ ])
|
|||||||
BOOST_CHECK_TYPE(const test_abc1&, boost::call_traits<test_abc1>::param_type);
|
BOOST_CHECK_TYPE(const test_abc1&, boost::call_traits<test_abc1>::param_type);
|
||||||
#else
|
#else
|
||||||
std::cout << "You're compiler does not support partial template specialiation, skipping 8 tests (8 errors)" << std::endl;
|
std::cout << "You're compiler does not support partial template specialiation, skipping 8 tests (8 errors)" << std::endl;
|
||||||
failures += 12;
|
|
||||||
test_count += 12;
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
std::cout << "You're compiler does not support partial template specialiation, skipping 20 tests (20 errors)" << std::endl;
|
std::cout << "You're compiler does not support partial template specialiation, skipping 20 tests (20 errors)" << std::endl;
|
||||||
failures += 24;
|
|
||||||
test_count += 24;
|
|
||||||
#endif
|
#endif
|
||||||
// test with an incomplete type:
|
// test with an incomplete type:
|
||||||
BOOST_CHECK_TYPE(incomplete_type, boost::call_traits<incomplete_type>::value_type);
|
BOOST_CHECK_TYPE(incomplete_type, boost::call_traits<incomplete_type>::value_type);
|
||||||
@ -327,12 +286,12 @@ int main(int argc, char *argv[ ])
|
|||||||
BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::const_reference);
|
BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::const_reference);
|
||||||
BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::param_type);
|
BOOST_CHECK_TYPE(const incomplete_type&, boost::call_traits<incomplete_type>::param_type);
|
||||||
|
|
||||||
return check_result(argc, argv);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// define call_traits tests to check that the assertions in the docs do actually work
|
// define call_traits tests to check that the assertions in the docs do actually work
|
||||||
// this is an instantiate only set of tests:
|
// this is an compile-time only set of tests:
|
||||||
//
|
//
|
||||||
template <typename T, bool isarray = false>
|
template <typename T, bool isarray = false>
|
||||||
struct call_traits_test
|
struct call_traits_test
|
||||||
@ -444,23 +403,3 @@ template struct call_traits_test<int[2], true>;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) && _MSC_VER <= 1300
|
|
||||||
unsigned int expected_failures = 12;
|
|
||||||
#elif defined(__SUNPRO_CC)
|
|
||||||
#if(__SUNPRO_CC <= 0x520)
|
|
||||||
unsigned int expected_failures = 18;
|
|
||||||
#elif(__SUNPRO_CC < 0x530)
|
|
||||||
unsigned int expected_failures = 17;
|
|
||||||
#else
|
|
||||||
unsigned int expected_failures = 6;
|
|
||||||
#endif
|
|
||||||
#elif defined(__BORLANDC__)
|
|
||||||
unsigned int expected_failures = 2;
|
|
||||||
#elif (defined(__GNUC__) && ((__GNUC__ < 3) || (__GNUC__ == 3) && (__GNUC_MINOR__ < 1)))
|
|
||||||
unsigned int expected_failures = 4;
|
|
||||||
#elif defined(__HP_aCC)
|
|
||||||
unsigned int expected_failures = 24;
|
|
||||||
#else
|
|
||||||
unsigned int expected_failures = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
@ -115,9 +115,8 @@ template<class T> struct checked_array_deleter
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<br>
|
<br>
|
||||||
<small>Copyright <20> 2002 by Peter Dimov. Permission to copy, use, modify, sell and
|
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
|
||||||
distribute this document is granted provided this copyright notice appears in
|
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
||||||
all copies. This document is provided "as is" without express or implied
|
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||||
warranty, and with no claim as to its suitability for any purpose.</small></p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<title>Header </title>
|
<title>Header </title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
|
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
|
||||||
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
|
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
|
||||||
<boostcompressed_pair.hpp>
|
<boostcompressed_pair.hpp>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">
|
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080">
|
||||||
@ -59,17 +59,18 @@ public:
|
|||||||
empty type, then assigning to that member will produce memory corruption,
|
empty type, then assigning to that member will produce memory corruption,
|
||||||
unless the empty type has a "do nothing" assignment operator defined. This is
|
unless the empty type has a "do nothing" assignment operator defined. This is
|
||||||
due to a bug in the way VC6 generates implicit assignment operators.</p>
|
due to a bug in the way VC6 generates implicit assignment operators.</p>
|
||||||
<hr>
|
<h3>Acknowledgements</h3>
|
||||||
<p>Revised 08 May 2001</p>
|
|
||||||
<p><EFBFBD> Copyright boost.org 2000. Permission to copy, use, modify, sell and
|
|
||||||
distribute this document is granted provided this copyright notice appears in
|
|
||||||
all copies. This document is provided "as is" without express or implied
|
|
||||||
warranty, and with no claim as to its suitability for any purpose.</p>
|
|
||||||
<p>Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John
|
<p>Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John
|
||||||
Maddock.</p>
|
Maddock.</p>
|
||||||
<p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John Maddock</a>, the
|
<p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John Maddock</a>, the
|
||||||
latest version of this file can be found at <a href="http://www.boost.org">www.boost.org</a>,
|
latest version of this file can be found at <a href="http://www.boost.org">www.boost.org</a>,
|
||||||
and the boost discussion list at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p>
|
and the boost discussion list at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p>
|
||||||
<p> </p>
|
<hr>
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->07 November 2007<!--webbot bot="Timestamp" endspan i-checksum="40338" --></p>
|
||||||
|
<p><EFBFBD> Copyright Beman Dawes, 2000.</p>
|
||||||
|
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||||
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -29,9 +29,8 @@
|
|||||||
function. On such compilers, the string literal has an unspecified value.</p>
|
function. On such compilers, the string literal has an unspecified value.</p>
|
||||||
<p>
|
<p>
|
||||||
<br>
|
<br>
|
||||||
<small>Copyright <20> 2002 by Peter Dimov. Permission to copy, use, modify, sell and
|
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
|
||||||
distribute this document is granted provided this copyright notice appears in
|
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
||||||
all copies. This document is provided "as is" without express or implied
|
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||||
warranty, and with no claim as to its suitability for any purpose.</small></p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
# Copyright David Abrahams 2003.
|
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
# For more information, see http://www.boost.org/
|
|
||||||
|
|
||||||
subproject libs/utility/enable_if/test ;
|
|
||||||
|
|
||||||
# bring in rules for testing
|
|
||||||
import testing ;
|
|
||||||
|
|
||||||
# Make tests run by default.
|
|
||||||
DEPENDS all : test ;
|
|
||||||
|
|
||||||
{
|
|
||||||
local test_monitor = <lib>@boost/libs/test/build/boost_test_exec_monitor ;
|
|
||||||
|
|
||||||
# look in BOOST_ROOT for sources first, just in this Jamfile
|
|
||||||
local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ;
|
|
||||||
|
|
||||||
test-suite utility/enable_if
|
|
||||||
:
|
|
||||||
[ run libs/utility/enable_if/test/constructors.cpp $(test_monitor) ]
|
|
||||||
[ run libs/utility/enable_if/test/dummy_arg_disambiguation.cpp $(test_monitor) ]
|
|
||||||
[ run libs/utility/enable_if/test/lazy.cpp $(test_monitor) ]
|
|
||||||
[ run libs/utility/enable_if/test/lazy_test.cpp $(test_monitor) ]
|
|
||||||
[ run libs/utility/enable_if/test/member_templates.cpp $(test_monitor) ]
|
|
||||||
[ run libs/utility/enable_if/test/namespace_disambiguation.cpp $(test_monitor) ]
|
|
||||||
[ run libs/utility/enable_if/test/no_disambiguation.cpp $(test_monitor) ]
|
|
||||||
[ run libs/utility/enable_if/test/partial_specializations.cpp $(test_monitor) ]
|
|
||||||
;
|
|
||||||
}
|
|
@ -1,33 +1,37 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Generator Iterator Adaptor Documentation</title>
|
<meta http-equiv="Content-Language" content="en-us">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
||||||
|
|
||||||
|
<title>Generator Iterator Adaptor Documentation</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#FFFFFF" text="#000000">
|
<body bgcolor="#FFFFFF" text="#000000">
|
||||||
|
<img src="../../boost.png" alt="boost.png (6897 bytes)" align="middle"
|
||||||
<img src="../../boost.png" alt="boost.png (6897 bytes)" align="center" width="277" height="86">
|
width="277" height="86">
|
||||||
|
|
||||||
<h1>Generator Iterator Adaptor</h1>
|
<h1>Generator Iterator Adaptor</h1>
|
||||||
Defined in header <a href="../../boost/generator_iterator.hpp">boost/generator_iterator.hpp</a>
|
|
||||||
<p>
|
|
||||||
The generator iterator adaptor makes it easier to create custom input
|
|
||||||
iterators from 0-ary functions and function objects. The adaptor
|
|
||||||
takes a
|
|
||||||
<a href="http://www.sgi.com/tech/stl/Generator.html">Generator</a>
|
|
||||||
and creates a model of
|
|
||||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.
|
|
||||||
Each increment retrieves an item from the generator and makes it
|
|
||||||
available to be retrieved by dereferencing. The motivation for this
|
|
||||||
iterator is that some concepts can be more naturally expressed as a
|
|
||||||
generator, while most STL algorithms expect an iterator. An example
|
|
||||||
is the <a href="../random/index.html">Random Number</a> library.
|
|
||||||
|
|
||||||
<h2>Synopsis</h2>
|
<p>Defined in header <a href=
|
||||||
|
"../../boost/generator_iterator.hpp">boost/generator_iterator.hpp</a></p>
|
||||||
|
|
||||||
<blockquote>
|
<p>The generator iterator adaptor makes it easier to create custom input
|
||||||
<pre>
|
iterators from 0-ary functions and function objects. The adaptor takes a
|
||||||
|
<a href="http://www.sgi.com/tech/stl/Generator.html">Generator</a> and
|
||||||
|
creates a model of <a href=
|
||||||
|
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>. Each
|
||||||
|
increment retrieves an item from the generator and makes it available to be
|
||||||
|
retrieved by dereferencing. The motivation for this iterator is that some
|
||||||
|
concepts can be more naturally expressed as a generator, while most STL
|
||||||
|
algorithms expect an iterator. An example is the <a href=
|
||||||
|
"../random/index.html">Random Number</a> library.</p>
|
||||||
|
|
||||||
|
<h2>Synopsis</h2>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<pre>
|
||||||
namespace boost {
|
namespace boost {
|
||||||
template <class Generator>
|
template <class Generator>
|
||||||
class generator_iterator_policies;
|
class generator_iterator_policies;
|
||||||
@ -40,21 +44,19 @@ namespace boost {
|
|||||||
make_generator_iterator(Generator & gen);
|
make_generator_iterator(Generator & gen);
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
<hr>
|
||||||
|
|
||||||
<hr>
|
<h2>The Generator Iterator Generator Class</h2>
|
||||||
|
|
||||||
<h2>The Generator Iterator Generator Class</h2>
|
<p>The class generator_iterator_generator is a helper class whose purpose
|
||||||
|
is to construct a generator iterator type. The template parameter for this
|
||||||
The class generator_iterator_generator is a helper class whose purpose
|
class is the Generator function object type that is being wrapped. The
|
||||||
is to construct a generator iterator type. The template parameter for
|
generator iterator adaptor only holds a reference (or pointer) to the
|
||||||
this class is the Generator function object type that is being
|
function object, therefore the function object must outlive the generator
|
||||||
wrapped. The generator iterator adaptor only holds a reference (or
|
iterator adaptor constructed from it.</p>
|
||||||
pointer) to the function object, therefore the function object must
|
<pre>
|
||||||
outlive the generator iterator adaptor constructed from it.
|
template <class Generator>
|
||||||
|
|
||||||
<pre>
|
|
||||||
template <class Generator>
|
|
||||||
class generator_iterator_generator
|
class generator_iterator_generator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -62,65 +64,65 @@ public:
|
|||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<h3>Template Parameters</h3>
|
||||||
|
|
||||||
<h3>Template Parameters</h3>
|
<table border summary="">
|
||||||
|
<tr>
|
||||||
|
<th>Parameter</th>
|
||||||
|
|
||||||
<table border>
|
<th>Description</th>
|
||||||
<tr>
|
</tr>
|
||||||
<th>Parameter</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><tt><a href="http://www.sgi.com/tech/stl/Generator.html">Generator</a></tt>
|
<td><tt><a href=
|
||||||
<td>The generator (0-ary function object) type being
|
"http://www.sgi.com/tech/stl/Generator.html">Generator</a></tt></td>
|
||||||
wrapped. The return type of the function must be defined as
|
|
||||||
<tt>Generator::result_type</tt>. The function object must be a model
|
|
||||||
of
|
|
||||||
<a href="http://www.sgi.com/tech/stl/Generator.html">Generator</a>.
|
|
||||||
</td>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h3>Concept Model</h3>
|
<td>The generator (0-ary function object) type being wrapped. The
|
||||||
The generator iterator class is a model of
|
return type of the function must be defined as
|
||||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.
|
<tt>Generator::result_type</tt>. The function object must be a model of
|
||||||
|
<a href=
|
||||||
|
"http://www.sgi.com/tech/stl/Generator.html">Generator</a>.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<h3>Members</h3>
|
<h3>Concept Model</h3>
|
||||||
The generator iterator implements the member functions
|
|
||||||
and operators required of the
|
|
||||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>
|
|
||||||
concept.
|
|
||||||
|
|
||||||
<br>
|
<p>The generator iterator class is a model of <a href=
|
||||||
|
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.</p>
|
||||||
|
|
||||||
<hr>
|
<h3>Members</h3>
|
||||||
<h2><a name="make_generator_iterator">The Generator Iterator Object Generator</a></h2>
|
|
||||||
|
|
||||||
The <tt>make_generator_iterator()</tt> function provides a
|
<p>The generator iterator implements the member functions and operators
|
||||||
convenient way to create generator iterator objects. The function
|
required of the <a href=
|
||||||
saves the user the trouble of explicitly writing out the iterator
|
"http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>
|
||||||
types.
|
concept.<br></p>
|
||||||
|
<hr>
|
||||||
|
|
||||||
<blockquote>
|
<h2><a name="make_generator_iterator" id="make_generator_iterator">The
|
||||||
<pre>
|
Generator Iterator Object Generator</a></h2>
|
||||||
|
|
||||||
|
<p>The <tt>make_generator_iterator()</tt> function provides a convenient
|
||||||
|
way to create generator iterator objects. The function saves the user the
|
||||||
|
trouble of explicitly writing out the iterator types.</p>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<pre>
|
||||||
template <class Generator>
|
template <class Generator>
|
||||||
typename generator_iterator_generator<Generator>::type
|
typename generator_iterator_generator<Generator>::type
|
||||||
make_generator_iterator(Generator & gen);
|
make_generator_iterator(Generator & gen);
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
<hr>
|
||||||
|
|
||||||
<hr>
|
<h3>Example</h3>
|
||||||
|
|
||||||
|
<p>The following program shows how <code>generator_iterator</code>
|
||||||
|
transforms a generator into an input iterator.</p>
|
||||||
|
|
||||||
<h3>Example</h3>
|
<blockquote>
|
||||||
|
<pre>
|
||||||
The following program shows how <code>generator_iterator</code>
|
#include <iostream>
|
||||||
transforms a generator into an input iterator.
|
#include <boost/generator_iterator.hpp>
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
<pre>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/generator_iterator.hpp>
|
|
||||||
|
|
||||||
class my_generator
|
class my_generator
|
||||||
{
|
{
|
||||||
@ -140,11 +142,22 @@ int main()
|
|||||||
std::cout << *it << std::endl;
|
std::cout << *it << std::endl;
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
<hr>
|
||||||
|
|
||||||
<hr>
|
<p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
|
||||||
|
"http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional"
|
||||||
|
height="31" width="88"></a></p>
|
||||||
|
|
||||||
Written by Jens Maurer.
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
|
||||||
|
|
||||||
|
<p><i>Copyright © 2001 <a href=
|
||||||
|
"http://www.boost.org/people/jens_maurer.htm">Jens Maurer</a></i></p>
|
||||||
|
|
||||||
|
<p><i>Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
|
||||||
|
copy at <a href=
|
||||||
|
"http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -3,9 +3,8 @@
|
|||||||
<HTML>
|
<HTML>
|
||||||
|
|
||||||
<HEAD>
|
<HEAD>
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||||
<LINK REL="stylesheet" TYPE="text/css" HREF="../../boost.css">
|
<TITLE>In_place_factory Documentation</TITLE>
|
||||||
<TITLE>Header </TITLE>
|
|
||||||
</HEAD>
|
</HEAD>
|
||||||
|
|
||||||
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
|
||||||
@ -77,7 +76,7 @@ object is likely to be temporary and serve no purpose besides being the source</
|
|||||||
</pre>
|
</pre>
|
||||||
<p>A solution to this problem is to support direct construction of the contained
|
<p>A solution to this problem is to support direct construction of the contained
|
||||||
object right in the container's storage.<br>
|
object right in the container's storage.<br>
|
||||||
In this shceme, the user supplies the arguments for the X constructor
|
In this scheme, the user supplies the arguments for the X constructor
|
||||||
directly to the container:</p>
|
directly to the container:</p>
|
||||||
<pre>struct C
|
<pre>struct C
|
||||||
{
|
{
|
||||||
@ -138,7 +137,7 @@ The following simplified example shows the basic idea. A complete example follow
|
|||||||
|
|
||||||
void foo()
|
void foo()
|
||||||
{
|
{
|
||||||
C c( in_place(123,"hello" ) ;
|
C c( in_place(123,"hello") ) ;
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// boost/assert.hpp - BOOST_ASSERT(expr)
|
// boost/assert.hpp - BOOST_ASSERT(expr)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
||||||
|
// Copyright (c) 2007 Peter Dimov
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -35,3 +36,15 @@ void assertion_failed(char const * expr, char const * function, char const * fil
|
|||||||
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
|
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
|
||||||
# define BOOST_ASSERT(expr) assert(expr)
|
# define BOOST_ASSERT(expr) assert(expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef BOOST_VERIFY
|
||||||
|
|
||||||
|
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
|
||||||
|
|
||||||
|
# define BOOST_VERIFY(expr) ((void)(expr))
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define BOOST_VERIFY(expr) BOOST_ASSERT(expr)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -32,6 +32,10 @@ inline void current_function_helper()
|
|||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||||
|
|
||||||
|
#elif defined(__DMC__) && (__DMC__ >= 0x810)
|
||||||
|
|
||||||
|
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
|
||||||
|
|
||||||
#elif defined(__FUNCSIG__)
|
#elif defined(__FUNCSIG__)
|
||||||
|
|
||||||
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
|
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
|
||||||
|
@ -58,7 +58,7 @@ struct ct_imp<T, isp, true>
|
|||||||
template <typename T, bool b1>
|
template <typename T, bool b1>
|
||||||
struct ct_imp<T, true, b1>
|
struct ct_imp<T, true, b1>
|
||||||
{
|
{
|
||||||
typedef T const param_type;
|
typedef const T param_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ struct call_traits<T&>
|
|||||||
typedef T& param_type; // hh removed const
|
typedef T& param_type; // hh removed const
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x570 ) )
|
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x581 ) )
|
||||||
// these are illegal specialisations; cv-qualifies applied to
|
// these are illegal specialisations; cv-qualifies applied to
|
||||||
// references have no effect according to [8.3.2p1],
|
// references have no effect according to [8.3.2p1],
|
||||||
// C++ Builder requires them though as it treats cv-qualified
|
// C++ Builder requires them though as it treats cv-qualified
|
||||||
@ -121,6 +121,15 @@ struct call_traits<T&const volatile>
|
|||||||
typedef const T& const_reference;
|
typedef const T& const_reference;
|
||||||
typedef T& param_type; // hh removed const
|
typedef T& param_type; // hh removed const
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct call_traits< T * >
|
||||||
|
{
|
||||||
|
typedef T * value_type;
|
||||||
|
typedef T * & reference;
|
||||||
|
typedef T * const & const_reference;
|
||||||
|
typedef T * const param_type; // hh removed const
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
|
#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/call_traits.hpp>
|
#include <boost/call_traits.hpp>
|
||||||
|
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable:4512)
|
||||||
|
#endif
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -132,7 +136,7 @@ namespace details
|
|||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
class compressed_pair_imp<T1, T2, 1>
|
class compressed_pair_imp<T1, T2, 1>
|
||||||
: private ::boost::remove_cv<T1>::type
|
: protected ::boost::remove_cv<T1>::type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T1 first_type;
|
typedef T1 first_type;
|
||||||
@ -174,7 +178,7 @@ namespace details
|
|||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
class compressed_pair_imp<T1, T2, 2>
|
class compressed_pair_imp<T1, T2, 2>
|
||||||
: private ::boost::remove_cv<T2>::type
|
: protected ::boost::remove_cv<T2>::type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T1 first_type;
|
typedef T1 first_type;
|
||||||
@ -217,8 +221,8 @@ namespace details
|
|||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
class compressed_pair_imp<T1, T2, 3>
|
class compressed_pair_imp<T1, T2, 3>
|
||||||
: private ::boost::remove_cv<T1>::type,
|
: protected ::boost::remove_cv<T1>::type,
|
||||||
private ::boost::remove_cv<T2>::type
|
protected ::boost::remove_cv<T2>::type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T1 first_type;
|
typedef T1 first_type;
|
||||||
@ -253,11 +257,14 @@ namespace details
|
|||||||
|
|
||||||
// JM
|
// JM
|
||||||
// 4 T1 == T2, T1 and T2 both empty
|
// 4 T1 == T2, T1 and T2 both empty
|
||||||
// Note does not actually store an instance of T2 at all -
|
// Originally this did not store an instance of T2 at all
|
||||||
// but reuses T1 base class for both first() and second().
|
// but that led to problems beause it meant &x.first() == &x.second()
|
||||||
|
// which is not true for any other kind of pair, so now we store an instance
|
||||||
|
// of T2 just in case the user is relying on first() and second() returning
|
||||||
|
// different objects (albeit both empty).
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
class compressed_pair_imp<T1, T2, 4>
|
class compressed_pair_imp<T1, T2, 4>
|
||||||
: private ::boost::remove_cv<T1>::type
|
: protected ::boost::remove_cv<T1>::type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T1 first_type;
|
typedef T1 first_type;
|
||||||
@ -428,5 +435,9 @@ swap(compressed_pair<T1, T2>& x, compressed_pair<T1, T2>& y)
|
|||||||
|
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // BOOST_DETAIL_COMPRESSED_PAIR_HPP
|
#endif // BOOST_DETAIL_COMPRESSED_PAIR_HPP
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
// See http://www.boost.org/libs/utility/operators.htm for documentation.
|
// See http://www.boost.org/libs/utility/operators.htm for documentation.
|
||||||
|
|
||||||
// Revision History
|
// Revision History
|
||||||
|
// 24 May 07 Changed empty_base to depend on T, see
|
||||||
|
// http://svn.boost.org/trac/boost/ticket/979
|
||||||
// 21 Oct 02 Modified implementation of operators to allow compilers with a
|
// 21 Oct 02 Modified implementation of operators to allow compilers with a
|
||||||
// correct named return value optimization (NRVO) to produce optimal
|
// correct named return value optimization (NRVO) to produce optimal
|
||||||
// code. (Daniel Frey)
|
// code. (Daniel Frey)
|
||||||
@ -90,15 +92,15 @@
|
|||||||
namespace boost {
|
namespace boost {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
template <typename T> class empty_base {
|
||||||
|
|
||||||
// Helmut Zeisel, empty base class optimization bug with GCC 3.0.0
|
// Helmut Zeisel, empty base class optimization bug with GCC 3.0.0
|
||||||
#if defined(__GNUC__) && __GNUC__==3 && __GNUC_MINOR__==0 && __GNU_PATCHLEVEL__==0
|
#if defined(__GNUC__) && __GNUC__==3 && __GNUC_MINOR__==0 && __GNU_PATCHLEVEL__==0
|
||||||
class empty_base {
|
|
||||||
bool dummy;
|
bool dummy;
|
||||||
};
|
|
||||||
#else
|
|
||||||
class empty_base {};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
@ -119,7 +121,7 @@ namespace boost
|
|||||||
// Note that friend functions defined in a class are implicitly inline.
|
// Note that friend functions defined in a class are implicitly inline.
|
||||||
// See the C++ std, 11.4 [class.friend] paragraph 5
|
// See the C++ std, 11.4 [class.friend] paragraph 5
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct less_than_comparable2 : B
|
struct less_than_comparable2 : B
|
||||||
{
|
{
|
||||||
friend bool operator<=(const T& x, const U& y) { return !(x > y); }
|
friend bool operator<=(const T& x, const U& y) { return !(x > y); }
|
||||||
@ -130,7 +132,7 @@ struct less_than_comparable2 : B
|
|||||||
friend bool operator>=(const U& x, const T& y) { return !(y > x); }
|
friend bool operator>=(const U& x, const T& y) { return !(y > x); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct less_than_comparable1 : B
|
struct less_than_comparable1 : B
|
||||||
{
|
{
|
||||||
friend bool operator>(const T& x, const T& y) { return y < x; }
|
friend bool operator>(const T& x, const T& y) { return y < x; }
|
||||||
@ -138,7 +140,7 @@ struct less_than_comparable1 : B
|
|||||||
friend bool operator>=(const T& x, const T& y) { return !(x < y); }
|
friend bool operator>=(const T& x, const T& y) { return !(x < y); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct equality_comparable2 : B
|
struct equality_comparable2 : B
|
||||||
{
|
{
|
||||||
friend bool operator==(const U& y, const T& x) { return x == y; }
|
friend bool operator==(const U& y, const T& x) { return x == y; }
|
||||||
@ -146,7 +148,7 @@ struct equality_comparable2 : B
|
|||||||
friend bool operator!=(const T& y, const U& x) { return !(y == x); }
|
friend bool operator!=(const T& y, const U& x) { return !(y == x); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct equality_comparable1 : B
|
struct equality_comparable1 : B
|
||||||
{
|
{
|
||||||
friend bool operator!=(const T& x, const T& y) { return !(x == y); }
|
friend bool operator!=(const T& x, const T& y) { return !(x == y); }
|
||||||
@ -165,7 +167,7 @@ struct equality_comparable1 : B
|
|||||||
// implementation available.
|
// implementation available.
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##2 : B \
|
struct NAME##2 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||||
@ -174,33 +176,33 @@ struct NAME##2 : B \
|
|||||||
{ T nrv( rhs ); nrv OP##= lhs; return nrv; } \
|
{ T nrv( rhs ); nrv OP##= lhs; return nrv; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##1 : B \
|
struct NAME##1 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##2 : B \
|
struct NAME##2 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##1 : B \
|
struct NAME##1 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||||
};
|
};
|
||||||
|
|
||||||
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||||
@ -210,35 +212,35 @@ struct NAME##1 : B \
|
|||||||
// BOOST_OPERATOR2_LEFT(NAME) only looks cool, but doesn't provide
|
// BOOST_OPERATOR2_LEFT(NAME) only looks cool, but doesn't provide
|
||||||
// optimization opportunities to the compiler :)
|
// optimization opportunities to the compiler :)
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##2 : B \
|
struct NAME##2 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||||
friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \
|
friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##1 : B \
|
struct NAME##1 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##2 : B \
|
struct NAME##2 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||||
{ return T( lhs ) OP##= rhs; } \
|
{ return T( lhs ) OP##= rhs; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##1 : B \
|
struct NAME##1 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||||
@ -261,7 +263,7 @@ BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | )
|
|||||||
|
|
||||||
// incrementable and decrementable contributed by Jeremy Siek
|
// incrementable and decrementable contributed by Jeremy Siek
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct incrementable : B
|
struct incrementable : B
|
||||||
{
|
{
|
||||||
friend T operator++(T& x, int)
|
friend T operator++(T& x, int)
|
||||||
@ -274,7 +276,7 @@ private: // The use of this typedef works around a Borland bug
|
|||||||
typedef T incrementable_type;
|
typedef T incrementable_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct decrementable : B
|
struct decrementable : B
|
||||||
{
|
{
|
||||||
friend T operator--(T& x, int)
|
friend T operator--(T& x, int)
|
||||||
@ -289,7 +291,7 @@ private: // The use of this typedef works around a Borland bug
|
|||||||
|
|
||||||
// Iterator operator classes (contributed by Jeremy Siek) ------------------//
|
// Iterator operator classes (contributed by Jeremy Siek) ------------------//
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||||
struct dereferenceable : B
|
struct dereferenceable : B
|
||||||
{
|
{
|
||||||
P operator->() const
|
P operator->() const
|
||||||
@ -298,7 +300,7 @@ struct dereferenceable : B
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class I, class R, class B = ::boost::detail::empty_base>
|
template <class T, class I, class R, class B = ::boost::detail::empty_base<T> >
|
||||||
struct indexable : B
|
struct indexable : B
|
||||||
{
|
{
|
||||||
R operator[](I n) const
|
R operator[](I n) const
|
||||||
@ -313,14 +315,14 @@ struct indexable : B
|
|||||||
#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##2 : B \
|
struct NAME##2 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##1 : B \
|
struct NAME##1 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||||
@ -330,13 +332,13 @@ struct NAME##1 : B \
|
|||||||
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||||
|
|
||||||
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##2 : B \
|
struct NAME##2 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct NAME##1 : B \
|
struct NAME##1 : B \
|
||||||
{ \
|
{ \
|
||||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||||
@ -349,7 +351,7 @@ BOOST_BINARY_OPERATOR( right_shiftable, >> )
|
|||||||
|
|
||||||
#undef BOOST_BINARY_OPERATOR
|
#undef BOOST_BINARY_OPERATOR
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct equivalent2 : B
|
struct equivalent2 : B
|
||||||
{
|
{
|
||||||
friend bool operator==(const T& x, const U& y)
|
friend bool operator==(const T& x, const U& y)
|
||||||
@ -358,7 +360,7 @@ struct equivalent2 : B
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct equivalent1 : B
|
struct equivalent1 : B
|
||||||
{
|
{
|
||||||
friend bool operator==(const T&x, const T&y)
|
friend bool operator==(const T&x, const T&y)
|
||||||
@ -367,7 +369,7 @@ struct equivalent1 : B
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct partially_ordered2 : B
|
struct partially_ordered2 : B
|
||||||
{
|
{
|
||||||
friend bool operator<=(const T& x, const U& y)
|
friend bool operator<=(const T& x, const U& y)
|
||||||
@ -384,7 +386,7 @@ struct partially_ordered2 : B
|
|||||||
{ return (y < x) || (y == x); }
|
{ return (y < x) || (y == x); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct partially_ordered1 : B
|
struct partially_ordered1 : B
|
||||||
{
|
{
|
||||||
friend bool operator>(const T& x, const T& y)
|
friend bool operator>(const T& x, const T& y)
|
||||||
@ -397,161 +399,161 @@ struct partially_ordered1 : B
|
|||||||
|
|
||||||
// Combined operator classes (contributed by Daryle Walker) ----------------//
|
// Combined operator classes (contributed by Daryle Walker) ----------------//
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct totally_ordered2
|
struct totally_ordered2
|
||||||
: less_than_comparable2<T, U
|
: less_than_comparable2<T, U
|
||||||
, equality_comparable2<T, U, B
|
, equality_comparable2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct totally_ordered1
|
struct totally_ordered1
|
||||||
: less_than_comparable1<T
|
: less_than_comparable1<T
|
||||||
, equality_comparable1<T, B
|
, equality_comparable1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct additive2
|
struct additive2
|
||||||
: addable2<T, U
|
: addable2<T, U
|
||||||
, subtractable2<T, U, B
|
, subtractable2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct additive1
|
struct additive1
|
||||||
: addable1<T
|
: addable1<T
|
||||||
, subtractable1<T, B
|
, subtractable1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct multiplicative2
|
struct multiplicative2
|
||||||
: multipliable2<T, U
|
: multipliable2<T, U
|
||||||
, dividable2<T, U, B
|
, dividable2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct multiplicative1
|
struct multiplicative1
|
||||||
: multipliable1<T
|
: multipliable1<T
|
||||||
, dividable1<T, B
|
, dividable1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct integer_multiplicative2
|
struct integer_multiplicative2
|
||||||
: multiplicative2<T, U
|
: multiplicative2<T, U
|
||||||
, modable2<T, U, B
|
, modable2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct integer_multiplicative1
|
struct integer_multiplicative1
|
||||||
: multiplicative1<T
|
: multiplicative1<T
|
||||||
, modable1<T, B
|
, modable1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct arithmetic2
|
struct arithmetic2
|
||||||
: additive2<T, U
|
: additive2<T, U
|
||||||
, multiplicative2<T, U, B
|
, multiplicative2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct arithmetic1
|
struct arithmetic1
|
||||||
: additive1<T
|
: additive1<T
|
||||||
, multiplicative1<T, B
|
, multiplicative1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct integer_arithmetic2
|
struct integer_arithmetic2
|
||||||
: additive2<T, U
|
: additive2<T, U
|
||||||
, integer_multiplicative2<T, U, B
|
, integer_multiplicative2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct integer_arithmetic1
|
struct integer_arithmetic1
|
||||||
: additive1<T
|
: additive1<T
|
||||||
, integer_multiplicative1<T, B
|
, integer_multiplicative1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct bitwise2
|
struct bitwise2
|
||||||
: xorable2<T, U
|
: xorable2<T, U
|
||||||
, andable2<T, U
|
, andable2<T, U
|
||||||
, orable2<T, U, B
|
, orable2<T, U, B
|
||||||
> > > {};
|
> > > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct bitwise1
|
struct bitwise1
|
||||||
: xorable1<T
|
: xorable1<T
|
||||||
, andable1<T
|
, andable1<T
|
||||||
, orable1<T, B
|
, orable1<T, B
|
||||||
> > > {};
|
> > > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct unit_steppable
|
struct unit_steppable
|
||||||
: incrementable<T
|
: incrementable<T
|
||||||
, decrementable<T, B
|
, decrementable<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct shiftable2
|
struct shiftable2
|
||||||
: left_shiftable2<T, U
|
: left_shiftable2<T, U
|
||||||
, right_shiftable2<T, U, B
|
, right_shiftable2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct shiftable1
|
struct shiftable1
|
||||||
: left_shiftable1<T
|
: left_shiftable1<T
|
||||||
, right_shiftable1<T, B
|
, right_shiftable1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ring_operators2
|
struct ring_operators2
|
||||||
: additive2<T, U
|
: additive2<T, U
|
||||||
, subtractable2_left<T, U
|
, subtractable2_left<T, U
|
||||||
, multipliable2<T, U, B
|
, multipliable2<T, U, B
|
||||||
> > > {};
|
> > > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ring_operators1
|
struct ring_operators1
|
||||||
: additive1<T
|
: additive1<T
|
||||||
, multipliable1<T, B
|
, multipliable1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ordered_ring_operators2
|
struct ordered_ring_operators2
|
||||||
: ring_operators2<T, U
|
: ring_operators2<T, U
|
||||||
, totally_ordered2<T, U, B
|
, totally_ordered2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ordered_ring_operators1
|
struct ordered_ring_operators1
|
||||||
: ring_operators1<T
|
: ring_operators1<T
|
||||||
, totally_ordered1<T, B
|
, totally_ordered1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct field_operators2
|
struct field_operators2
|
||||||
: ring_operators2<T, U
|
: ring_operators2<T, U
|
||||||
, dividable2<T, U
|
, dividable2<T, U
|
||||||
, dividable2_left<T, U, B
|
, dividable2_left<T, U, B
|
||||||
> > > {};
|
> > > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct field_operators1
|
struct field_operators1
|
||||||
: ring_operators1<T
|
: ring_operators1<T
|
||||||
, dividable1<T, B
|
, dividable1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ordered_field_operators2
|
struct ordered_field_operators2
|
||||||
: field_operators2<T, U
|
: field_operators2<T, U
|
||||||
, totally_ordered2<T, U, B
|
, totally_ordered2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ordered_field_operators1
|
struct ordered_field_operators1
|
||||||
: field_operators1<T
|
: field_operators1<T
|
||||||
, totally_ordered1<T, B
|
, totally_ordered1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct euclidian_ring_operators2
|
struct euclidian_ring_operators2
|
||||||
: ring_operators2<T, U
|
: ring_operators2<T, U
|
||||||
, dividable2<T, U
|
, dividable2<T, U
|
||||||
@ -560,43 +562,43 @@ struct euclidian_ring_operators2
|
|||||||
, modable2_left<T, U, B
|
, modable2_left<T, U, B
|
||||||
> > > > > {};
|
> > > > > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct euclidian_ring_operators1
|
struct euclidian_ring_operators1
|
||||||
: ring_operators1<T
|
: ring_operators1<T
|
||||||
, dividable1<T
|
, dividable1<T
|
||||||
, modable1<T, B
|
, modable1<T, B
|
||||||
> > > {};
|
> > > {};
|
||||||
|
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base>
|
template <class T, class U, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ordered_euclidian_ring_operators2
|
struct ordered_euclidian_ring_operators2
|
||||||
: totally_ordered2<T, U
|
: totally_ordered2<T, U
|
||||||
, euclidian_ring_operators2<T, U, B
|
, euclidian_ring_operators2<T, U, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct ordered_euclidian_ring_operators1
|
struct ordered_euclidian_ring_operators1
|
||||||
: totally_ordered1<T
|
: totally_ordered1<T
|
||||||
, euclidian_ring_operators1<T, B
|
, euclidian_ring_operators1<T, B
|
||||||
> > {};
|
> > {};
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||||
struct input_iteratable
|
struct input_iteratable
|
||||||
: equality_comparable1<T
|
: equality_comparable1<T
|
||||||
, incrementable<T
|
, incrementable<T
|
||||||
, dereferenceable<T, P, B
|
, dereferenceable<T, P, B
|
||||||
> > > {};
|
> > > {};
|
||||||
|
|
||||||
template <class T, class B = ::boost::detail::empty_base>
|
template <class T, class B = ::boost::detail::empty_base<T> >
|
||||||
struct output_iteratable
|
struct output_iteratable
|
||||||
: incrementable<T, B
|
: incrementable<T, B
|
||||||
> {};
|
> {};
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||||
struct forward_iteratable
|
struct forward_iteratable
|
||||||
: input_iteratable<T, P, B
|
: input_iteratable<T, P, B
|
||||||
> {};
|
> {};
|
||||||
|
|
||||||
template <class T, class P, class B = ::boost::detail::empty_base>
|
template <class T, class P, class B = ::boost::detail::empty_base<T> >
|
||||||
struct bidirectional_iteratable
|
struct bidirectional_iteratable
|
||||||
: forward_iteratable<T, P
|
: forward_iteratable<T, P
|
||||||
, decrementable<T, B
|
, decrementable<T, B
|
||||||
@ -606,7 +608,7 @@ struct bidirectional_iteratable
|
|||||||
// which is an indirect base class of bidirectional_iterable,
|
// which is an indirect base class of bidirectional_iterable,
|
||||||
// random_access_iteratable must not be derived from totally_ordered1
|
// random_access_iteratable must not be derived from totally_ordered1
|
||||||
// but from less_than_comparable1 only. (Helmut Zeisel, 02-Dec-2001)
|
// but from less_than_comparable1 only. (Helmut Zeisel, 02-Dec-2001)
|
||||||
template <class T, class P, class D, class R, class B = ::boost::detail::empty_base>
|
template <class T, class P, class D, class R, class B = ::boost::detail::empty_base<T> >
|
||||||
struct random_access_iteratable
|
struct random_access_iteratable
|
||||||
: bidirectional_iteratable<T, P
|
: bidirectional_iteratable<T, P
|
||||||
, less_than_comparable1<T
|
, less_than_comparable1<T
|
||||||
@ -650,20 +652,20 @@ struct random_access_iteratable
|
|||||||
|
|
||||||
// Otherwise, because a Borland C++ 5.5 bug prevents a using declaration
|
// Otherwise, because a Borland C++ 5.5 bug prevents a using declaration
|
||||||
// from working, we are forced to use inheritance for that compiler.
|
// from working, we are forced to use inheritance for that compiler.
|
||||||
# define BOOST_IMPORT_TEMPLATE4(template_name) \
|
# define BOOST_IMPORT_TEMPLATE4(template_name) \
|
||||||
template <class T, class U, class V, class W, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class V, class W, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct template_name : ::template_name<T, U, V, W, B> {};
|
struct template_name : ::template_name<T, U, V, W, B> {};
|
||||||
|
|
||||||
# define BOOST_IMPORT_TEMPLATE3(template_name) \
|
# define BOOST_IMPORT_TEMPLATE3(template_name) \
|
||||||
template <class T, class U, class V, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class V, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct template_name : ::template_name<T, U, V, B> {};
|
struct template_name : ::template_name<T, U, V, B> {};
|
||||||
|
|
||||||
# define BOOST_IMPORT_TEMPLATE2(template_name) \
|
# define BOOST_IMPORT_TEMPLATE2(template_name) \
|
||||||
template <class T, class U, class B = ::boost::detail::empty_base> \
|
template <class T, class U, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct template_name : ::template_name<T, U, B> {};
|
struct template_name : ::template_name<T, U, B> {};
|
||||||
|
|
||||||
# define BOOST_IMPORT_TEMPLATE1(template_name) \
|
# define BOOST_IMPORT_TEMPLATE1(template_name) \
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct template_name : ::template_name<T, B> {};
|
struct template_name : ::template_name<T, B> {};
|
||||||
|
|
||||||
# endif // BOOST_NO_USING_TEMPLATE
|
# endif // BOOST_NO_USING_TEMPLATE
|
||||||
@ -752,7 +754,7 @@ template<class T> struct is_chained_base {
|
|||||||
# define BOOST_OPERATOR_TEMPLATE(template_name) \
|
# define BOOST_OPERATOR_TEMPLATE(template_name) \
|
||||||
template <class T \
|
template <class T \
|
||||||
,class U = T \
|
,class U = T \
|
||||||
,class B = ::boost::detail::empty_base \
|
,class B = ::boost::detail::empty_base<T> \
|
||||||
,class O = typename is_chained_base<U>::value \
|
,class O = typename is_chained_base<U>::value \
|
||||||
> \
|
> \
|
||||||
struct template_name : template_name##2<T, U, B> {}; \
|
struct template_name : template_name##2<T, U, B> {}; \
|
||||||
@ -788,7 +790,7 @@ BOOST_OPERATOR_TEMPLATE1(template_name##1)
|
|||||||
// In this case we can only assume that template_name<> is equivalent to the
|
// In this case we can only assume that template_name<> is equivalent to the
|
||||||
// more commonly needed template_name1<> form.
|
// more commonly needed template_name1<> form.
|
||||||
# define BOOST_OPERATOR_TEMPLATE(template_name) \
|
# define BOOST_OPERATOR_TEMPLATE(template_name) \
|
||||||
template <class T, class B = ::boost::detail::empty_base> \
|
template <class T, class B = ::boost::detail::empty_base<T> > \
|
||||||
struct template_name : template_name##1<T, B> {};
|
struct template_name : template_name##1<T, B> {};
|
||||||
|
|
||||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/utility/addressof.hpp>
|
#include <boost/utility/addressof.hpp>
|
||||||
#include <boost/mpl/bool.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
|
#include <boost/detail/workaround.hpp>
|
||||||
|
|
||||||
//
|
//
|
||||||
// ref.hpp - ref/cref, useful helper functions
|
// ref.hpp - ref/cref, useful helper functions
|
||||||
@ -33,7 +34,7 @@ template<class T> class reference_wrapper
|
|||||||
public:
|
public:
|
||||||
typedef T type;
|
typedef T type;
|
||||||
|
|
||||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
|
||||||
|
|
||||||
explicit reference_wrapper(T& t): t_(&t) {}
|
explicit reference_wrapper(T& t): t_(&t) {}
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ private:
|
|||||||
T* t_;
|
T* t_;
|
||||||
};
|
};
|
||||||
|
|
||||||
# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x570)
|
# if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
|
||||||
# define BOOST_REF_CONST
|
# define BOOST_REF_CONST
|
||||||
# else
|
# else
|
||||||
# define BOOST_REF_CONST const
|
# define BOOST_REF_CONST const
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||||
|
// Copyright (C) 2007, Tobias Schwinger.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -9,25 +10,27 @@
|
|||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
//
|
//
|
||||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
|
||||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include <cstddef>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
#include <boost/preprocessor/punctuation/paren.hpp>
|
||||||
|
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||||
|
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum.hpp>
|
#include <boost/preprocessor/repetition/enum.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
||||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
|
||||||
#include <boost/preprocessor/punctuation/paren.hpp>
|
|
||||||
#include <boost/preprocessor/facilities/empty.hpp>
|
|
||||||
|
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT(z,n,_) BOOST_PP_CAT(m_a,n) BOOST_PP_LPAREN() BOOST_PP_CAT(a,n) BOOST_PP_RPAREN()
|
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT(z,n,_) BOOST_PP_CAT(m_a,n) BOOST_PP_LPAREN() BOOST_PP_CAT(a,n) BOOST_PP_RPAREN()
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL(z,n,_) BOOST_PP_CAT(A,n) const& BOOST_PP_CAT(m_a,n);
|
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL(z,n,_) BOOST_PP_CAT(A,n) const& BOOST_PP_CAT(m_a,n);
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG(z,n,_) BOOST_PP_CAT(m_a,n)
|
|
||||||
|
|
||||||
#define BOOST_MAX_INPLACE_FACTORY_ARITY 10
|
#define BOOST_MAX_INPLACE_FACTORY_ARITY 10
|
||||||
|
|
||||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||||
|
// Copyright (C) 2007, Tobias Schwinger.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -9,15 +10,14 @@
|
|||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
//
|
//
|
||||||
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
#ifndef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
|
||||||
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_25AGO2003_HPP
|
#define BOOST_UTILITY_DETAIL_INPLACE_FACTORY_SUFFIX_04APR2007_HPP
|
||||||
|
|
||||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT
|
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT
|
||||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL
|
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL
|
||||||
#undef BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_ARG
|
|
||||||
#undef BOOST_MAX_INPLACE_FACTORY_ARITY
|
#undef BOOST_MAX_INPLACE_FACTORY_ARITY
|
||||||
|
|
||||||
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_25AGO2003_HPP
|
#undef BOOST_UTILITY_DETAIL_INPLACE_FACTORY_PREFIX_04APR2007_HPP
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -21,66 +21,69 @@
|
|||||||
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||||
: detail::result_of<F, F(BOOST_RESULT_OF_ARGS)> {};
|
: boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef BOOST_RESULT_OF_ARGS
|
||||||
|
|
||||||
|
#if BOOST_PP_ITERATION() >= 1
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<R (*)(BOOST_RESULT_OF_ARGS), FArgs>
|
struct result_of_impl<R (*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||||
{
|
{
|
||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<R (&)(BOOST_RESULT_OF_ARGS), FArgs>
|
struct result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), FArgs, false>
|
||||||
{
|
{
|
||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef BOOST_RESULT_OF_ARGS
|
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||||
|
|
||||||
#if BOOST_PP_ITERATION() > 1 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<R (T0::*)
|
struct result_of_impl<R (T0::*)
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
|
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),
|
||||||
FArgs>
|
FArgs, false>
|
||||||
{
|
{
|
||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<R (T0::*)
|
struct result_of_impl<R (T0::*)
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||||
const,
|
const,
|
||||||
FArgs>
|
FArgs, false>
|
||||||
{
|
{
|
||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<R (T0::*)
|
struct result_of_impl<R (T0::*)
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||||
volatile,
|
volatile,
|
||||||
FArgs>
|
FArgs, false>
|
||||||
{
|
{
|
||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename R, typename FArgs BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<R (T0::*)
|
struct result_of_impl<R (T0::*)
|
||||||
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T))
|
||||||
const volatile,
|
const volatile,
|
||||||
FArgs>
|
FArgs, false>
|
||||||
{
|
{
|
||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||||
|
// Copyright (C) 2007, Tobias Schwinger.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -9,50 +10,79 @@
|
|||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
//
|
//
|
||||||
#ifndef BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
|
#ifndef BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
|
||||||
#define BOOST_UTILITY_INPLACE_FACTORY_25AGO2003_HPP
|
#ifndef BOOST_PP_IS_ITERATING
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
||||||
|
|
||||||
#include <boost/type.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
class in_place_factory_base {} ;
|
class in_place_factory_base {} ;
|
||||||
|
|
||||||
#define BOOST_DEFINE_INPLACE_FACTORY_CLASS(z,n,_) \
|
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
|
||||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
#define BOOST_PP_FILENAME_1 <boost/utility/in_place_factory.hpp>
|
||||||
class BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) : public in_place_factory_base \
|
#include BOOST_PP_ITERATE()
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
\
|
|
||||||
BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
|
|
||||||
: \
|
|
||||||
BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
|
|
||||||
{} \
|
|
||||||
\
|
|
||||||
template<class T> \
|
|
||||||
void apply ( void* address BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T) ) const \
|
|
||||||
{ \
|
|
||||||
new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
|
|
||||||
} ; \
|
|
||||||
\
|
|
||||||
template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
|
||||||
BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
|
|
||||||
{ \
|
|
||||||
return BOOST_PP_CAT(in_place_factory, BOOST_PP_INC(n) ) < BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
|
|
||||||
} ; \
|
|
||||||
|
|
||||||
BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
||||||
|
|
||||||
|
#define BOOST_UTILITY_INPLACE_FACTORY_04APR2007_HPP
|
||||||
|
#else
|
||||||
|
#define N BOOST_PP_ITERATION()
|
||||||
|
|
||||||
|
#if N
|
||||||
|
template< BOOST_PP_ENUM_PARAMS(N, class A) >
|
||||||
|
#endif
|
||||||
|
class BOOST_PP_CAT(in_place_factory,N)
|
||||||
|
:
|
||||||
|
public in_place_factory_base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit BOOST_PP_CAT(in_place_factory,N)
|
||||||
|
( BOOST_PP_ENUM_BINARY_PARAMS(N,A,const& a) )
|
||||||
|
#if N > 0
|
||||||
|
: BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
|
||||||
|
#endif
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void* apply(void* address
|
||||||
|
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
|
||||||
|
{
|
||||||
|
return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void* apply(void* address, std::size_t n
|
||||||
|
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) const
|
||||||
|
{
|
||||||
|
for(char* next = address = this->BOOST_NESTED_TEMPLATE apply<T>(address);
|
||||||
|
!! --n;)
|
||||||
|
this->BOOST_NESTED_TEMPLATE apply<T>(next = next+sizeof(T));
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
|
||||||
|
};
|
||||||
|
|
||||||
|
#if N > 0
|
||||||
|
template< BOOST_PP_ENUM_PARAMS(N, class A) >
|
||||||
|
inline BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
|
||||||
|
in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
|
||||||
|
{
|
||||||
|
return BOOST_PP_CAT(in_place_factory,N)< BOOST_PP_ENUM_PARAMS(N, A) >
|
||||||
|
( BOOST_PP_ENUM_PARAMS(N, a) );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
inline in_place_factory0 in_place()
|
||||||
|
{
|
||||||
|
return in_place_factory0();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef N
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -10,11 +10,14 @@
|
|||||||
#define BOOST_RESULT_OF_HPP
|
#define BOOST_RESULT_OF_HPP
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/type_traits/ice.hpp>
|
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||||
#include <boost/type.hpp>
|
#include <boost/preprocessor/punctuation/comma_if.hpp>
|
||||||
#include <boost/preprocessor.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
|
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/detail/workaround.hpp>
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
|
#include <boost/mpl/if.hpp>
|
||||||
|
#include <boost/mpl/bool.hpp>
|
||||||
|
|
||||||
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
||||||
# define BOOST_RESULT_OF_NUM_ARGS 10
|
# define BOOST_RESULT_OF_NUM_ARGS 10
|
||||||
@ -29,28 +32,48 @@ namespace detail {
|
|||||||
|
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
||||||
|
|
||||||
template<typename F, typename FArgs, bool HasResultType> struct get_result_of;
|
template<typename F, typename FArgs, bool HasResultType> struct result_of_impl;
|
||||||
|
|
||||||
template<typename F, typename FArgs>
|
|
||||||
struct get_result_of<F, FArgs, true>
|
|
||||||
{
|
|
||||||
typedef typename F::result_type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename F, typename FArgs>
|
|
||||||
struct get_result_of<F, FArgs, false>
|
|
||||||
{
|
|
||||||
typedef typename F::template result<FArgs>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
struct get_result_of<F, F(void), false>
|
struct result_of_void_impl
|
||||||
{
|
{
|
||||||
typedef void type;
|
typedef void type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename R>
|
||||||
|
struct result_of_void_impl<R (*)(void)>
|
||||||
|
{
|
||||||
|
typedef R type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename R>
|
||||||
|
struct result_of_void_impl<R (&)(void)>
|
||||||
|
{
|
||||||
|
typedef R type;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename F, typename FArgs>
|
template<typename F, typename FArgs>
|
||||||
struct result_of : get_result_of<F, FArgs, (has_result_type<F>::value)> {};
|
struct result_of_impl<F, FArgs, true>
|
||||||
|
{
|
||||||
|
typedef typename F::result_type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename FArgs>
|
||||||
|
struct is_function_with_no_args : mpl::false_ {};
|
||||||
|
|
||||||
|
template<typename F>
|
||||||
|
struct is_function_with_no_args<F(void)> : mpl::true_ {};
|
||||||
|
|
||||||
|
template<typename F, typename FArgs>
|
||||||
|
struct result_of_nested_result : F::template result<FArgs>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<typename F, typename FArgs>
|
||||||
|
struct result_of_impl<F, FArgs, false>
|
||||||
|
: mpl::if_<is_function_with_no_args<FArgs>,
|
||||||
|
result_of_void_impl<F>,
|
||||||
|
result_of_nested_result<F, FArgs> >::type
|
||||||
|
{};
|
||||||
|
|
||||||
} // end namespace detail
|
} // end namespace detail
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||||
|
// Copyright (C) 2007, Tobias Schwinger.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -9,8 +10,8 @@
|
|||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
//
|
//
|
||||||
#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
|
#ifndef BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP
|
||||||
#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_25AGO2003_HPP
|
#ifndef BOOST_PP_IS_ITERATING
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
#include <boost/utility/detail/in_place_factory_prefix.hpp>
|
||||||
|
|
||||||
@ -18,40 +19,59 @@ namespace boost {
|
|||||||
|
|
||||||
class typed_in_place_factory_base {} ;
|
class typed_in_place_factory_base {} ;
|
||||||
|
|
||||||
#define BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS(z,n,_) \
|
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_MAX_INPLACE_FACTORY_ARITY)
|
||||||
template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
#define BOOST_PP_FILENAME_1 <boost/utility/typed_in_place_factory.hpp>
|
||||||
class BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) : public typed_in_place_factory_base \
|
#include BOOST_PP_ITERATE()
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
\
|
|
||||||
typedef T value_type ; \
|
|
||||||
\
|
|
||||||
BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A,const& a) ) \
|
|
||||||
: \
|
|
||||||
BOOST_PP_ENUM( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _ ) \
|
|
||||||
{} \
|
|
||||||
\
|
|
||||||
void apply ( void* address ) const \
|
|
||||||
{ \
|
|
||||||
new ( address ) T ( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), m_a ) ) ; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
BOOST_PP_REPEAT( BOOST_PP_INC(n), BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _) \
|
|
||||||
} ; \
|
|
||||||
\
|
|
||||||
template< class T, BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n),class A) > \
|
|
||||||
BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T , BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
in_place ( BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_INC(n),A, const& a) ) \
|
|
||||||
{ \
|
|
||||||
return BOOST_PP_CAT(typed_in_place_factory, BOOST_PP_INC(n) ) < T, BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), A ) > \
|
|
||||||
( BOOST_PP_ENUM_PARAMS( BOOST_PP_INC(n), a ) ) ; \
|
|
||||||
} ; \
|
|
||||||
|
|
||||||
BOOST_PP_REPEAT( BOOST_MAX_INPLACE_FACTORY_ARITY, BOOST_DEFINE_TYPED_INPLACE_FACTORY_CLASS, BOOST_PP_EMPTY() )
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
#include <boost/utility/detail/in_place_factory_suffix.hpp>
|
||||||
|
|
||||||
|
#define BOOST_UTILITY_TYPED_INPLACE_FACTORY_04APR2007_HPP
|
||||||
|
#else
|
||||||
|
#define N BOOST_PP_ITERATION()
|
||||||
|
|
||||||
|
template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N,class A) >
|
||||||
|
class BOOST_PP_CAT(typed_in_place_factory,N)
|
||||||
|
:
|
||||||
|
public typed_in_place_factory_base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef T value_type;
|
||||||
|
|
||||||
|
explicit BOOST_PP_CAT(typed_in_place_factory,N)
|
||||||
|
( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
|
||||||
|
#if N > 0
|
||||||
|
: BOOST_PP_ENUM(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_INIT, _)
|
||||||
|
#endif
|
||||||
|
{}
|
||||||
|
|
||||||
|
void* apply (void* address) const
|
||||||
|
{
|
||||||
|
return new(address) T( BOOST_PP_ENUM_PARAMS(N, m_a) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void* apply (void* address, std::size_t n) const
|
||||||
|
{
|
||||||
|
for(void* next = address = this->apply(address); !! --n;)
|
||||||
|
this->apply(next = static_cast<char *>(next) + sizeof(T));
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_PP_REPEAT(N, BOOST_DEFINE_INPLACE_FACTORY_CLASS_MEMBER_DECL, _)
|
||||||
|
};
|
||||||
|
|
||||||
|
template< class T BOOST_PP_ENUM_TRAILING_PARAMS(N, class A) >
|
||||||
|
inline BOOST_PP_CAT(typed_in_place_factory,N)<
|
||||||
|
T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) >
|
||||||
|
in_place( BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a) )
|
||||||
|
{
|
||||||
|
return BOOST_PP_CAT(typed_in_place_factory,N)<
|
||||||
|
T BOOST_PP_ENUM_TRAILING_PARAMS(N, A) >( BOOST_PP_ENUM_PARAMS(N, a) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef N
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,64 +1,100 @@
|
|||||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
// (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
// 21 Ago 2002 (Created) Fernando Cacciola
|
// 21 Ago 2002 (Created) Fernando Cacciola
|
||||||
|
// 30 Jan 2008 (Worked around compiler bugs, added initialized_value) Fernando Cacciola, Niels Dekker
|
||||||
//
|
//
|
||||||
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
#ifndef BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
||||||
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
#define BOOST_UTILITY_VALUE_INIT_21AGO2002_HPP
|
||||||
|
|
||||||
#include "boost/detail/select_type.hpp"
|
// Note: The implementation of boost::value_initialized had to deal with the
|
||||||
#include "boost/type_traits/cv_traits.hpp"
|
// fact that various compilers haven't fully implemented value-initialization.
|
||||||
|
// The constructor of boost::value_initialized<T> works around these compiler
|
||||||
|
// issues, by clearing the bytes of T, before constructing the T object it
|
||||||
|
// contains. More details on these issues are at libs/utility/value_init.htm
|
||||||
|
|
||||||
|
#include <boost/aligned_storage.hpp>
|
||||||
|
#include <boost/detail/workaround.hpp>
|
||||||
|
#include <boost/type_traits/cv_traits.hpp>
|
||||||
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
|
#include <cstring>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
namespace vinit_detail {
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class const_T_base
|
class value_initialized
|
||||||
{
|
{
|
||||||
protected :
|
private :
|
||||||
|
struct wrapper
|
||||||
|
{
|
||||||
|
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
||||||
|
typename
|
||||||
|
#endif
|
||||||
|
remove_const<T>::type data;
|
||||||
|
};
|
||||||
|
|
||||||
const_T_base() : x() {}
|
mutable
|
||||||
|
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
|
||||||
|
typename
|
||||||
|
#endif
|
||||||
|
aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
|
||||||
|
|
||||||
T x ;
|
wrapper * wrapper_address() const
|
||||||
} ;
|
{
|
||||||
|
return static_cast<wrapper *>( static_cast<void*>(&x));
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct non_const_T_base
|
|
||||||
{
|
|
||||||
protected :
|
|
||||||
|
|
||||||
non_const_T_base() : x() {}
|
|
||||||
|
|
||||||
mutable T x ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct select_base
|
|
||||||
{
|
|
||||||
typedef typename
|
|
||||||
detail::if_true< ::boost::is_const<T>::value >
|
|
||||||
::template then< const_T_base<T>, non_const_T_base<T> >::type type ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
} // namespace vinit_detail
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class value_initialized : private vinit_detail::select_base<T>::type
|
|
||||||
{
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
value_initialized() {}
|
value_initialized()
|
||||||
|
{
|
||||||
|
std::memset(&x, 0, sizeof(x));
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(push)
|
||||||
|
#if _MSC_VER >= 1310
|
||||||
|
// When using MSVC 7.1 or higher, the following placement new expression may trigger warning C4345:
|
||||||
|
// "behavior change: an object of POD type constructed with an initializer of the form ()
|
||||||
|
// will be default-initialized". It is safe to ignore this warning when using value_initialized.
|
||||||
|
#pragma warning(disable: 4345)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
new (wrapper_address()) wrapper();
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
operator T&() const { return this->x ; }
|
value_initialized(value_initialized const & arg)
|
||||||
|
{
|
||||||
|
new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
|
||||||
|
}
|
||||||
|
|
||||||
T& data() const { return this->x ; }
|
value_initialized & operator=(value_initialized const & arg)
|
||||||
|
{
|
||||||
|
this->data() = static_cast<T const &>( arg.data() );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~value_initialized()
|
||||||
|
{
|
||||||
|
wrapper_address()->wrapper::~wrapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
T& data() const
|
||||||
|
{
|
||||||
|
return wrapper_address()->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator T&() const { return this->data(); }
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T const& get ( value_initialized<T> const& x )
|
T const& get ( value_initialized<T> const& x )
|
||||||
{
|
{
|
||||||
@ -70,8 +106,19 @@ T& get ( value_initialized<T>& x )
|
|||||||
return x.data() ;
|
return x.data() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class initialized_value
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
|
||||||
|
template <class T> operator T() const
|
||||||
|
{
|
||||||
|
return get( value_initialized<T>() );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
12
index.html
12
index.html
@ -19,6 +19,7 @@
|
|||||||
<a href="call_traits.htm">call_traits</a><br>
|
<a href="call_traits.htm">call_traits</a><br>
|
||||||
<a href="checked_delete.html">checked_delete</a><br>
|
<a href="checked_delete.html">checked_delete</a><br>
|
||||||
<a href="compressed_pair.htm">compressed_pair</a><br>
|
<a href="compressed_pair.htm">compressed_pair</a><br>
|
||||||
|
<a href="current_function.html">current_function</a><br>
|
||||||
<a href="enable_if.html">enable_if</a><br>
|
<a href="enable_if.html">enable_if</a><br>
|
||||||
<a href="iterator_adaptors.htm">iterator_adaptors</a><br>
|
<a href="iterator_adaptors.htm">iterator_adaptors</a><br>
|
||||||
<a href="operators.htm">operators</a><br>
|
<a href="operators.htm">operators</a><br>
|
||||||
@ -27,8 +28,13 @@
|
|||||||
<a href="value_init.htm">value_init</a></p>
|
<a href="value_init.htm">value_init</a></p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<hr>
|
<hr>
|
||||||
|
<p><EFBFBD> Copyright Beman Dawes, 2001</p>
|
||||||
|
<p>Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
accompanying file <a href="../../LICENSE_1_0.txt">
|
||||||
|
LICENSE_1_0.txt</a> or copy at
|
||||||
|
<a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||||
|
www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||||
<p>Revised
|
<p>Revised
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->01 September, 2003<!--webbot bot="Timestamp" endspan i-checksum="38582" --></p>
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->07 November, 2006<!--webbot bot="Timestamp" endspan i-checksum="39368" --></p>
|
||||||
<p> </p>
|
</body>
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -2029,13 +2029,13 @@ public:
|
|||||||
<h2><a name="contributors">Contributors</a></h2>
|
<h2><a name="contributors">Contributors</a></h2>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt><a href="../../people/dave_abrahams.htm">Dave Abrahams</a></dt>
|
<dt><a href="http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a></dt>
|
||||||
|
|
||||||
<dd>Started the library and contributed the arithmetic operators in
|
<dd>Started the library and contributed the arithmetic operators in
|
||||||
<cite><a href=
|
<cite><a href=
|
||||||
"../../boost/operators.hpp">boost/operators.hpp</a></cite>.</dd>
|
"../../boost/operators.hpp">boost/operators.hpp</a></cite>.</dd>
|
||||||
|
|
||||||
<dt><a href="../../people/jeremy_siek.htm">Jeremy Siek</a></dt>
|
<dt><a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a></dt>
|
||||||
|
|
||||||
<dd>Contributed the <a href="#deref">dereference operators and iterator
|
<dd>Contributed the <a href="#deref">dereference operators and iterator
|
||||||
helpers</a> in <cite><a href=
|
helpers</a> in <cite><a href=
|
||||||
@ -2043,19 +2043,19 @@ public:
|
|||||||
contributed <cite><a href=
|
contributed <cite><a href=
|
||||||
"iterators_test.cpp">iterators_test.cpp</a></cite>.</dd>
|
"iterators_test.cpp">iterators_test.cpp</a></cite>.</dd>
|
||||||
|
|
||||||
<dt><a href="../../people/aleksey_gurtovoy.htm">Aleksey
|
<dt><a href="http://www.boost.org/people/aleksey_gurtovoy.htm">Aleksey
|
||||||
Gurtovoy</a></dt>
|
Gurtovoy</a></dt>
|
||||||
|
|
||||||
<dd>Contributed the code to support <a href="#chaining">base class
|
<dd>Contributed the code to support <a href="#chaining">base class
|
||||||
chaining</a> while remaining backward-compatible with old versions of
|
chaining</a> while remaining backward-compatible with old versions of
|
||||||
the library.</dd>
|
the library.</dd>
|
||||||
|
|
||||||
<dt><a href="../../people/beman_dawes.html">Beman Dawes</a></dt>
|
<dt><a href="http://www.boost.org/people/beman_dawes.html">Beman Dawes</a></dt>
|
||||||
|
|
||||||
<dd>Contributed <cite><a href=
|
<dd>Contributed <cite><a href=
|
||||||
"operators_test.cpp">operators_test.cpp</a></cite>.</dd>
|
"operators_test.cpp">operators_test.cpp</a></cite>.</dd>
|
||||||
|
|
||||||
<dt><a href="../../people/daryle_walker.html">Daryle Walker</a></dt>
|
<dt><a href="http://www.boost.org/people/daryle_walker.html">Daryle Walker</a></dt>
|
||||||
|
|
||||||
<dd>Contributed classes for the shift operators, equivalence, partial
|
<dd>Contributed classes for the shift operators, equivalence, partial
|
||||||
ordering, and arithmetic conversions. Added the grouped operator
|
ordering, and arithmetic conversions. Added the grouped operator
|
||||||
|
@ -315,7 +315,7 @@ Last modified: Mon Aug 11 11:27:03 EST 2003
|
|||||||
<p><EFBFBD> Copyright 2003 The Trustees of Indiana University.
|
<p><EFBFBD> Copyright 2003 The Trustees of Indiana University.
|
||||||
Use, modification and distribution is subject to the Boost Software
|
Use, modification and distribution is subject to the Boost Software
|
||||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
http:www.boost.org/LICENSE_1_0.txt)</p>
|
http://www.boost.org/LICENSE_1_0.txt)</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
43
test/Jamfile
43
test/Jamfile
@ -1,43 +0,0 @@
|
|||||||
# Copyright David Abrahams 2003. Permission to copy, use,
|
|
||||||
# modify, sell and distribute this software is granted provided this
|
|
||||||
# copyright notice appears in all copies. This software is provided
|
|
||||||
# "as is" without express or implied warranty, and with no claim as
|
|
||||||
# to its suitability for any purpose.
|
|
||||||
|
|
||||||
# For more information, see http://www.boost.org/
|
|
||||||
|
|
||||||
subproject libs/utility/test ;
|
|
||||||
|
|
||||||
# bring in rules for testing
|
|
||||||
import testing ;
|
|
||||||
|
|
||||||
# Make tests run by default.
|
|
||||||
DEPENDS all : test ;
|
|
||||||
|
|
||||||
local test_monitor = <lib>@boost/libs/test/build/boost_test_exec_monitor ;
|
|
||||||
|
|
||||||
# Please keep the tests ordered by filename
|
|
||||||
test-suite utility
|
|
||||||
:
|
|
||||||
[ run ../addressof_test.cpp ]
|
|
||||||
[ run ../assert_test.cpp ]
|
|
||||||
[ run ../base_from_member_test.cpp ]
|
|
||||||
[ run ../binary_search_test.cpp ]
|
|
||||||
[ run ../call_traits_test.cpp : -u ]
|
|
||||||
[ compile-fail ../checked_delete_test.cpp ]
|
|
||||||
[ run ../compressed_pair_test.cpp $(test_monitor) : -u ]
|
|
||||||
[ run ../current_function_test.cpp : : : <test-info>always_show_run_output ]
|
|
||||||
[ run ../iterators_test.cpp $(test_monitor) ]
|
|
||||||
[ run next_prior_test.cpp $(test_monitor) ]
|
|
||||||
[ compile-fail ../noncopyable_test.cpp ]
|
|
||||||
[ run ../numeric_traits_test.cpp ]
|
|
||||||
[ run ../operators_test.cpp $(test_monitor) ]
|
|
||||||
[ compile ../ref_ct_test.cpp ]
|
|
||||||
[ run ../ref_test.cpp $(test_monitor) ]
|
|
||||||
[ compile result_of_test.cpp ]
|
|
||||||
[ run ../shared_iterator_test.cpp ]
|
|
||||||
[ run ../value_init_test.cpp ]
|
|
||||||
[ compile-fail ../value_init_test_fail1.cpp ]
|
|
||||||
[ compile-fail ../value_init_test_fail2.cpp ]
|
|
||||||
[ compile-fail ../value_init_test_fail3.cpp ]
|
|
||||||
;
|
|
@ -1,8 +1,7 @@
|
|||||||
# Copyright David Abrahams 2003. Permission to copy, use,
|
# Copyright David Abrahams 2003.
|
||||||
# modify, sell and distribute this software is granted provided this
|
|
||||||
# copyright notice appears in all copies. This software is provided
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# "as is" without express or implied warranty, and with no claim as
|
# See http://www.boost.org/LICENSE_1_0.txt
|
||||||
# to its suitability for any purpose.
|
|
||||||
|
|
||||||
# For more information, see http://www.boost.org/
|
# For more information, see http://www.boost.org/
|
||||||
|
|
||||||
@ -18,19 +17,21 @@ test-suite utility
|
|||||||
[ run ../binary_search_test.cpp ]
|
[ run ../binary_search_test.cpp ]
|
||||||
[ run ../call_traits_test.cpp : -u ]
|
[ run ../call_traits_test.cpp : -u ]
|
||||||
[ compile-fail ../checked_delete_test.cpp ]
|
[ compile-fail ../checked_delete_test.cpp ]
|
||||||
[ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor : -u ]
|
[ run ../compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/<link>static : -u ]
|
||||||
[ run ../current_function_test.cpp : : : <test-info>always_show_run_output ]
|
[ run ../current_function_test.cpp : : : <test-info>always_show_run_output ]
|
||||||
[ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor ]
|
[ run ../iterators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||||
[ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor ]
|
[ run next_prior_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||||
[ compile-fail ../noncopyable_test.cpp ]
|
[ compile-fail ../noncopyable_test.cpp ]
|
||||||
[ run ../numeric_traits_test.cpp ]
|
[ run ../numeric_traits_test.cpp ]
|
||||||
[ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor ]
|
[ run ../operators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||||
[ compile ../ref_ct_test.cpp ]
|
[ compile ../ref_ct_test.cpp ]
|
||||||
[ run ../ref_test.cpp ../../test/build//boost_test_exec_monitor ]
|
[ run ../ref_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ]
|
||||||
[ compile result_of_test.cpp ]
|
[ compile result_of_test.cpp ]
|
||||||
[ run ../shared_iterator_test.cpp ]
|
[ run ../shared_iterator_test.cpp ]
|
||||||
[ run ../value_init_test.cpp ]
|
[ run ../value_init_test.cpp ]
|
||||||
[ compile-fail ../value_init_test_fail1.cpp ]
|
[ compile-fail ../value_init_test_fail1.cpp ]
|
||||||
[ compile-fail ../value_init_test_fail2.cpp ]
|
[ compile-fail ../value_init_test_fail2.cpp ]
|
||||||
[ compile-fail ../value_init_test_fail3.cpp ]
|
[ compile-fail ../value_init_test_fail3.cpp ]
|
||||||
|
[ run ../verify_test.cpp ]
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -24,6 +24,24 @@ struct int_result_type_and_float_result_of
|
|||||||
template<typename F> struct result { typedef float type; };
|
template<typename F> struct result { typedef float type; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct int_result_type_template { typedef int result_type; };
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct int_result_of_template
|
||||||
|
{
|
||||||
|
template<typename F> struct result;
|
||||||
|
template<typename This, typename That> struct result<This(That)> { typedef int type; };
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct int_result_type_and_float_result_of_template
|
||||||
|
{
|
||||||
|
typedef int result_type;
|
||||||
|
template<typename F> struct result;
|
||||||
|
template<typename This, typename That> struct result<This(That)> { typedef float type; };
|
||||||
|
};
|
||||||
|
|
||||||
struct X {};
|
struct X {};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -32,10 +50,13 @@ int main()
|
|||||||
|
|
||||||
typedef int (*func_ptr)(float, double);
|
typedef int (*func_ptr)(float, double);
|
||||||
typedef int (&func_ref)(float, double);
|
typedef int (&func_ref)(float, double);
|
||||||
|
typedef int (*func_ptr_0)();
|
||||||
|
typedef int (&func_ref_0)();
|
||||||
typedef int (X::*mem_func_ptr)(float);
|
typedef int (X::*mem_func_ptr)(float);
|
||||||
typedef int (X::*mem_func_ptr_c)(float) const;
|
typedef int (X::*mem_func_ptr_c)(float) const;
|
||||||
typedef int (X::*mem_func_ptr_v)(float) volatile;
|
typedef int (X::*mem_func_ptr_v)(float) volatile;
|
||||||
typedef int (X::*mem_func_ptr_cv)(float) const volatile;
|
typedef int (X::*mem_func_ptr_cv)(float) const volatile;
|
||||||
|
typedef int (X::*mem_func_ptr_0)();
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
|
||||||
@ -43,11 +64,22 @@ int main()
|
|||||||
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(char)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ref_0()>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr(X,char)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr(X,char)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_c(X,char)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_c(X,char)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_v(X,char)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_v(X,char)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_cv(X,char)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_cv(X,char)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,8 @@ template<class E> void throw_exception(E const & e)
|
|||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
<p><br>
|
<p><br>
|
||||||
<small>Copyright <20> 2002 by Peter Dimov. Permission to copy, use, modify, sell and
|
<small>Copyright <20> 2002 by Peter Dimov. Distributed under the Boost Software License, Version
|
||||||
distribute this document is granted provided this copyright notice appears in
|
1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or
|
||||||
all copies. This document is provided "as is" without express or implied
|
copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||||
warranty, and with no claim as to its suitability for any purpose.</small></p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
23
utility.htm
23
utility.htm
@ -23,6 +23,7 @@
|
|||||||
<li>
|
<li>
|
||||||
Function template <a href="#addressof">addressof()</a></li>
|
Function template <a href="#addressof">addressof()</a></li>
|
||||||
<li>Class template <a href="#result_of">result_of</a></li>
|
<li>Class template <a href="#result_of">result_of</a></li>
|
||||||
|
<li><a href="index.html">Other utilities not part of <code>utility.hpp</code></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2>
|
<h2>
|
||||||
Function templates <a name="checked_delete">checked_delete</a>() and
|
Function templates <a name="checked_delete">checked_delete</a>() and
|
||||||
@ -67,7 +68,7 @@ const std::list<T>::iterator next = boost::next(prev, 2);</pre>
|
|||||||
<p>The distance from the given iterator should be supplied as an absolute value. For
|
<p>The distance from the given iterator should be supplied as an absolute value. For
|
||||||
example, the iterator four iterators prior to the given iterator <code>p</code>
|
example, the iterator four iterators prior to the given iterator <code>p</code>
|
||||||
may be obtained by <code>prior(p, 4)</code>.</p>
|
may be obtained by <code>prior(p, 4)</code>.</p>
|
||||||
<p>Contributed by <a href="../../people/dave_abrahams.htm">Dave Abrahams</a>. Two-argument versions by Daniel Walker.</p>
|
<p>Contributed by <a href="http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a>. Two-argument versions by Daniel Walker.</p>
|
||||||
<h2><a name="Class_noncopyable">Class noncopyable</a></h2>
|
<h2><a name="Class_noncopyable">Class noncopyable</a></h2>
|
||||||
<p>Class <strong>noncopyable</strong> is a base class. Derive your own class
|
<p>Class <strong>noncopyable</strong> is a base class. Derive your own class
|
||||||
from <strong>noncopyable</strong> when you want to prohibit copy construction
|
from <strong>noncopyable</strong> when you want to prohibit copy construction
|
||||||
@ -88,7 +89,7 @@ const std::list<T>::iterator next = boost::next(prev, 2);</pre>
|
|||||||
to verify class <b>noncopyable</b> works as expected. It has have been run
|
to verify class <b>noncopyable</b> works as expected. It has have been run
|
||||||
successfully under GCC 2.95, Metrowerks CodeWarrior 5.0, and Microsoft Visual
|
successfully under GCC 2.95, Metrowerks CodeWarrior 5.0, and Microsoft Visual
|
||||||
C++ 6.0 sp 3.</p>
|
C++ 6.0 sp 3.</p>
|
||||||
<p>Contributed by <a href="../../people/dave_abrahams.htm">Dave Abrahams</a>.</p>
|
<p>Contributed by <a href="http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a>.</p>
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>// inside one of your own headers ...
|
<pre>// inside one of your own headers ...
|
||||||
@ -162,9 +163,9 @@ void f() {
|
|||||||
<code><em>N</em> > 0</code> or <code>void</code>
|
<code><em>N</em> > 0</code> or <code>void</code>
|
||||||
when <code><em>N</em> = 0</code>. For additional
|
when <code><em>N</em> = 0</code>. For additional
|
||||||
information about <code>result_of</code>, see the
|
information about <code>result_of</code>, see the
|
||||||
current draft of the C++ Library TR, <a
|
C++ Library Technical Report, <a
|
||||||
href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2004/n1647.pdf">N1647</a>,
|
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">N1836</a>,
|
||||||
or the <code>result_of</code> <a
|
or, for motivation and design rationale, the <code>result_of</code> <a
|
||||||
href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1454.html">proposal</a>.</p>
|
href="http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1454.html">proposal</a>.</p>
|
||||||
|
|
||||||
<p>Class template <code>result_of</code> resides in
|
<p>Class template <code>result_of</code> resides in
|
||||||
@ -182,12 +183,12 @@ void f() {
|
|||||||
<p>See <a href="base_from_member.html">separate documentation</a>.</p>
|
<p>See <a href="base_from_member.html">separate documentation</a>.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Revised <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan
|
<p>Revised <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan
|
||||||
-->02 May, 2004<!--webbot bot="Timestamp" endspan i-checksum="38582"
|
-->07 November, 2007<!--webbot bot="Timestamp" endspan i-checksum="39369"
|
||||||
-->
|
-->
|
||||||
</p>
|
</p>
|
||||||
<p>© Copyright boost.org 1999-2003. Permission to copy, use, modify, sell and distribute
|
<p>© Copyright Beman Dawes 1999-2003.</p>
|
||||||
this document is granted provided this copyright notice appears in all copies.
|
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||||
This document is provided "as is" without express or implied
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
|
||||||
warranty, and with no claim as to its suitability for any purpose.</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
229
value_init.htm
229
value_init.htm
@ -17,11 +17,13 @@
|
|||||||
<dl>
|
<dl>
|
||||||
<dt><a href="#rationale">Rationale</a></dt>
|
<dt><a href="#rationale">Rationale</a></dt>
|
||||||
<dt><a href="#intro">Introduction</a></dt>
|
<dt><a href="#intro">Introduction</a></dt>
|
||||||
|
<dt><a href="#details">Details</a></dt>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#valueinit">value-initialization</a></li>
|
<li><a href="#valueinit">value-initialization</a></li>
|
||||||
<li><a href="#valueinitsyn">value-initialization syntax</a></li>
|
<li><a href="#valueinitsyn">value-initialization syntax</a></li>
|
||||||
|
<li><a href="#compiler_issues">compiler issues</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -30,7 +32,8 @@
|
|||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#val_init"><code>value_initialized<></code></a></li>
|
<li><a href="#val_init"><code>template class value_initialized<T></code></a></li>
|
||||||
|
<li><a href="#initialized_value"><code>class initialized_value</code></a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<a href="#acknowledgements">Acknowledgements</a><br>
|
<a href="#acknowledgements">Acknowledgements</a><br>
|
||||||
@ -44,24 +47,104 @@
|
|||||||
for initialization. Depending on the type, the value of a newly constructed
|
for initialization. Depending on the type, the value of a newly constructed
|
||||||
object can be zero-initialized (logically 0), default-constructed (using
|
object can be zero-initialized (logically 0), default-constructed (using
|
||||||
the default constructor), or indeterminate. When writing generic code,
|
the default constructor), or indeterminate. When writing generic code,
|
||||||
this problem must be addressed. <code>value_initialized</code> provides
|
this problem must be addressed. The template <code>value_initialized</code> provides
|
||||||
a solution with consistent syntax for value initialization of scalar,
|
a solution with consistent syntax for value initialization of scalar,
|
||||||
union and class types. <br>
|
union and class types.
|
||||||
|
Moreover, <code>value_initialized</code> offers a workaround to various
|
||||||
|
compiler issues regarding value-initialization.
|
||||||
|
|
||||||
|
Furthermore a convenience class, <code>initialized_value</code> is provided,
|
||||||
|
to avoid repeating the type name when retrieving the value from a
|
||||||
|
<code>value_initialized<T></code> object.
|
||||||
|
<br>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2><a name="intro"></a>Introduction</h2>
|
<h2><a name="intro"></a>Introduction</h2>
|
||||||
|
|
||||||
<p>The C++ standard [<a href="#references">1</a>] contains the definitions
|
<p>
|
||||||
|
There are various ways to initialize a variable, in C++. The following
|
||||||
|
declarations all <em>may</em> have a local variable initialized to its default
|
||||||
|
value:
|
||||||
|
<pre>
|
||||||
|
T1 var1;
|
||||||
|
T2 var2 = 0;
|
||||||
|
T3 var3 = {};
|
||||||
|
T4 var4 = T4();
|
||||||
|
</pre>
|
||||||
|
Unfortunately, whether or not any of those declarations correctly
|
||||||
|
initialize the variable very much depends on its type. The first
|
||||||
|
declaration is valid for any <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">
|
||||||
|
DefaultConstructible</a> type (by definition).
|
||||||
|
However, it does not always do an initialization!
|
||||||
|
It correctly initializes the variable when it's an instance of a
|
||||||
|
class, and the author of the class has provided a proper default
|
||||||
|
constructor. On the other hand, the value of <code>var1</code> is <em>indeterminate</em> when
|
||||||
|
its type is an arithmetic type, like <code>int</code>, <code>float</code>, or <code>char</code>.
|
||||||
|
An arithmetic variable
|
||||||
|
is of course initialized properly by the second declaration, <code>T2
|
||||||
|
var2 = 0</code>. But this initialization form usually won't work for a
|
||||||
|
class type (unless the class was especially written to support being
|
||||||
|
initialized that way). The third form, <code>T3 var3 = {}</code>
|
||||||
|
initializes an aggregate, typically a "C-style" <code>struct</code> or a "C-style" array.
|
||||||
|
However, the syntax is not allowed for a class that has an explicitly declared
|
||||||
|
constructor. (But watch out for an upcoming C++ language change,
|
||||||
|
by Bjarne Stroustrup et al [<a href="#references">1</a>]!)
|
||||||
|
The fourth form is the most generic form of them, as it
|
||||||
|
can be used to initialize arithmetic types, class types, aggregates, pointers, and
|
||||||
|
other types. The declaration, <code>T4 var4 = T4()</code>, should be read
|
||||||
|
as follows: First a temporary object is created, by <code>T4()</code>.
|
||||||
|
This object is <a href="#valueinit">value-initialized</a>. Next the temporary
|
||||||
|
object is copied to the named variable, <code>var4</code>. Afterwards, the temporary
|
||||||
|
is destroyed. While the copying and the destruction are likely to
|
||||||
|
be optimized away, C++ still requires the type <code>T4</code> to be
|
||||||
|
<a href="CopyConstructible.html">CopyConstructible</a>.
|
||||||
|
(So <code>T4</code> needs to be <em>both</em> DefaultConstructible <em>and</em> CopyConstructible.)
|
||||||
|
A class may not be CopyConstructible, for example because it may have a
|
||||||
|
private and undefined copy constructor,
|
||||||
|
or because it may be derived from <a href="utility.htm#Class_noncopyable">boost::noncopyable</a>.
|
||||||
|
Scott Meyers [<a href="#references">2</a>] explains why a class would be defined like that.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
There is another, less obvious disadvantage to the fourth form, <code>T4 var4 = T4()</code>:
|
||||||
|
It suffers from various <a href="#compiler_issues">compiler issues</a>, causing
|
||||||
|
a variable to be left uninitialized in some compiler specific cases.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The template <a href="#val_init"><code>value_initialized</code></a>
|
||||||
|
offers a generic way to initialize
|
||||||
|
an object, like <code>T4 var4 = T4()</code>, but without requiring its type
|
||||||
|
to be CopyConstructible. And it offers a workaround to those compiler issues
|
||||||
|
regarding value-initialization as well! It allows getting an initialized
|
||||||
|
variable of any type; it <em>only</em> requires the type to be DefaultConstructible.
|
||||||
|
A properly <em>value-initialized</em> object of type <code>T</code> is
|
||||||
|
constructed by the following declaration:
|
||||||
|
<pre>
|
||||||
|
value_initialized<T> var;
|
||||||
|
</pre>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The convenience class <a href="#initialized_value"><code>initialized_value</code></a>
|
||||||
|
allows value-initializing a variable as follows:
|
||||||
|
<pre>
|
||||||
|
T var = initialized_value();
|
||||||
|
</pre>
|
||||||
|
This form of initialization is also very similar to <code>T4 var4 = T4()</code>,
|
||||||
|
but robust against the aforementioned compiler issues.
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2><a name="details"></a>Details</h2>
|
||||||
|
<p>The C++ standard [<a href="#references">3</a>] contains the definitions
|
||||||
of <code>zero-initialization</code> and <code>default-initialization</code>.
|
of <code>zero-initialization</code> and <code>default-initialization</code>.
|
||||||
Informally, zero-initialization means that the object is given the initial
|
Informally, zero-initialization means that the object is given the initial
|
||||||
value 0 (converted to the type) and default-initialization means that
|
value 0 (converted to the type) and default-initialization means that
|
||||||
POD [<a href="#references">2</a>] types are zero-initialized, while class
|
POD [<a href="#references">4</a>] types are zero-initialized, while non-POD class
|
||||||
types are initialized with their corresponding default constructors. A
|
types are initialized with their corresponding default constructors. A
|
||||||
<i>declaration</i> can contain an <i>initializer</i>, which specifies the
|
<i>declaration</i> can contain an <i>initializer</i>, which specifies the
|
||||||
object's initial value. The initializer can be just '()', which states that
|
object's initial value. The initializer can be just '()', which states that
|
||||||
the object shall be default-initialized (but see below). However, if a <i>declaration</i>
|
the object shall be value-initialized (but see below). However, if a <i>declaration</i>
|
||||||
has no <i>initializer</i> and it is of a non-<code>const</code>, non-<code>static</code>
|
has no <i>initializer</i> and it is of a non-<code>const</code>, non-<code>static</code>
|
||||||
POD type, the initial value is indeterminate:<cite>(see §8.5 for the
|
POD type, the initial value is indeterminate: <cite>(see §8.5, [dcl.init], for the
|
||||||
accurate definitions).</cite></p>
|
accurate definitions).</cite></p>
|
||||||
|
|
||||||
<pre>int x ; // no initializer. x value is indeterminate.<br>std::string s ; // no initializer, s is default-constructed.<br><br>int y = int() ; <br>// y is initialized using copy-initialization<br>// but the temporary uses an empty set of parentheses as the initializer,<br>// so it is default-constructed.<br>// A default constructed POD type is zero-initialized,<br>// therefore, y == 0.<br><br>void foo ( std::string ) ;<br>foo ( std::string() ) ; <br>// the temporary string is default constructed <br>// as indicated by the initializer () </pre>
|
<pre>int x ; // no initializer. x value is indeterminate.<br>std::string s ; // no initializer, s is default-constructed.<br><br>int y = int() ; <br>// y is initialized using copy-initialization<br>// but the temporary uses an empty set of parentheses as the initializer,<br>// so it is default-constructed.<br>// A default constructed POD type is zero-initialized,<br>// therefore, y == 0.<br><br>void foo ( std::string ) ;<br>foo ( std::string() ) ; <br>// the temporary string is default constructed <br>// as indicated by the initializer () </pre>
|
||||||
@ -87,14 +170,11 @@ the object shall be default-initialized (but see below). However, if a <i>decla
|
|||||||
<p>In order to specify value-initialization of an object we need to use the
|
<p>In order to specify value-initialization of an object we need to use the
|
||||||
empty-set initializer: (). </p>
|
empty-set initializer: (). </p>
|
||||||
|
|
||||||
<p><i>(but recall that the current C++ Standard states that '()' invokes default-initialization,
|
|
||||||
not value-initialization)</i></p>
|
|
||||||
|
|
||||||
<p>As before, a declaration with no intializer specifies default-initialization,
|
<p>As before, a declaration with no intializer specifies default-initialization,
|
||||||
and a declaration with a non-empty initializer specifies copy (=xxx) or
|
and a declaration with a non-empty initializer specifies copy (=xxx) or
|
||||||
direct (xxx) initialization. </p>
|
direct (xxx) initialization. </p>
|
||||||
|
|
||||||
<pre>template<class T> void eat(T);<br>int x ; // indeterminate initial value.<br>std::string s; // default-initialized.<br>eat ( int() ) ; // value-initialized<br>eat ( std::string() ) ; // value-initialied</pre>
|
<pre>template<class T> void eat(T);<br>int x ; // indeterminate initial value.<br>std::string s; // default-initialized.<br>eat ( int() ) ; // value-initialized<br>eat ( std::string() ) ; // value-initialized</pre>
|
||||||
|
|
||||||
<h4><a name="valueinitsyn">value-initialization</a> syntax</h4>
|
<h4><a name="valueinitsyn">value-initialization</a> syntax</h4>
|
||||||
|
|
||||||
@ -102,7 +182,7 @@ not value-initialization)</i></p>
|
|||||||
parentheses is not permitted by the syntax of initializers because it is
|
parentheses is not permitted by the syntax of initializers because it is
|
||||||
parsed as the declaration of a function taking no arguments: </p>
|
parsed as the declaration of a function taking no arguments: </p>
|
||||||
|
|
||||||
<pre>int x() ; // declares function int(*)()<br>int y ( int() ) ; // decalares function int(*)( int(*)() )</pre>
|
<pre>int x() ; // declares function int(*)()</pre>
|
||||||
|
|
||||||
<p>Thus, the empty () must be put in some other initialization context.</p>
|
<p>Thus, the empty () must be put in some other initialization context.</p>
|
||||||
|
|
||||||
@ -124,8 +204,50 @@ data member:</p>
|
|||||||
|
|
||||||
<pre>template<class T> <br>struct W <br>{<br> // value-initialization of 'data' here.<br> W() : data() {}<br> T data ;<br>} ;<br>W<int> w ;<br>// w.data is value-initialized for any type. </pre>
|
<pre>template<class T> <br>struct W <br>{<br> // value-initialization of 'data' here.<br> W() : data() {}<br> T data ;<br>} ;<br>W<int> w ;<br>// w.data is value-initialized for any type. </pre>
|
||||||
|
|
||||||
<p><code>This is the solution supplied by the value_initialized<> template
|
<p>This is the solution as it was supplied by earlier versions of the
|
||||||
class.</code></p>
|
<code>value_initialized<T></code> template
|
||||||
|
class. Unfortunately this approach suffered from various compiler issues.</p>
|
||||||
|
|
||||||
|
<h4><a name="compiler_issues">compiler issues</a> </h4>
|
||||||
|
|
||||||
|
Various compilers haven't yet fully implemented value-initialization.
|
||||||
|
So when an object should be <em>value-initialized</em> (according to the C++ Standard),
|
||||||
|
it <em>may</em> in practice still be left uninitialized, because of those
|
||||||
|
compiler issues! It's hard to make a general statement on what those issues
|
||||||
|
are like, because they depend on the compiler you are using, its version number,
|
||||||
|
and the type of object you would like to have value-initialized.
|
||||||
|
Compilers usually support value-initialization for built-in types properly.
|
||||||
|
But objects of user-defined types that involve <em>aggregates</em> may <em>in some cases</em>
|
||||||
|
be partially, or even entirely left uninitialized, when they should be value-initialized.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
We have encountered issues regarding value-initialization on compilers by
|
||||||
|
Microsoft, Sun, Borland, and GNU. Here is a list of bug reports on those issues:
|
||||||
|
<table summary="Compiler bug reports regarding value-initialization" border="0" cellpadding="7" cellspacing="1" >
|
||||||
|
<tr><td>
|
||||||
|
<a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744">
|
||||||
|
Microsoft Feedback ID 100744 - Value-initialization in new-expression</a>
|
||||||
|
<br>Reported by Pavel Kuznetsov (MetaCommunications Engineering), 2005-07-28
|
||||||
|
<br>
|
||||||
|
<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111">
|
||||||
|
GCC Bug 30111 - Value-initialization of POD base class doesn't initialize members</a>
|
||||||
|
<br>Reported by Jonathan Wakely, 2006-12-07
|
||||||
|
<br>
|
||||||
|
<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916">
|
||||||
|
GCC Bug 33916 - Default constructor fails to initialize array members</a>
|
||||||
|
<br>Reported by Michael Elizabeth Chastain, 2007-10-26
|
||||||
|
<br>
|
||||||
|
<a href="http://qc.codegear.com/wc/qcmain.aspx?d=51854">
|
||||||
|
Borland Report 51854 - Value-initialization: POD struct should be zero-initialized</a>
|
||||||
|
<br>Reported by Niels Dekker (LKEB, Leiden University Medical Center), 2007-09-11
|
||||||
|
<br>
|
||||||
|
</td></tr></table>
|
||||||
|
</p><p>
|
||||||
|
New versions of <code>value_initialized</code>
|
||||||
|
(Boost release version 1.35 or higher)
|
||||||
|
offer a workaround to these issues: <code>value_initialized</code> will now clear
|
||||||
|
its internal data, prior to constructing the object that it contains.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h2><a name="types"></a>Types</h2>
|
<h2><a name="types"></a>Types</h2>
|
||||||
|
|
||||||
@ -189,31 +311,78 @@ wrapped object from within a constant wrapper can be avoided if access to
|
|||||||
the wrapped object is always performed with the <code>get()</code> idiom:</p>
|
the wrapped object is always performed with the <code>get()</code> idiom:</p>
|
||||||
|
|
||||||
<pre>value_initialized<int> x ;<br>get(x) = 1 ; // OK<br><br>value_initialized<int const> cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized<int> const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized<int const> const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre>
|
<pre>value_initialized<int> x ;<br>get(x) = 1 ; // OK<br><br>value_initialized<int const> cx ;<br>get(x) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized<int> const x_c ;<br>get(x_c) = 1 ; // ERROR: Cannot modify a const object<br><br>value_initialized<int const> const cx_c ;<br>get(cx_c) = 1 ; // ERROR: Cannot modify a const object<br></pre>
|
||||||
|
|
||||||
|
<h2><a name="initialized_value"><code>class initialized_value</code></a></h2>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
namespace boost {
|
||||||
|
class initialized_value
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
template <class T> operator T() const ;
|
||||||
|
};
|
||||||
|
} // namespace boost
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
The class <code>initialized_value</code> provides a convenient way to get
|
||||||
|
an initialized value: its conversion operator provides an appropriate
|
||||||
|
<em>value-initialized</em> object for any CopyConstructible type.
|
||||||
|
|
||||||
|
Suppose you need to have an initialized variable of type <code>T</code>.
|
||||||
|
You could do it as follows:
|
||||||
|
<pre>
|
||||||
|
T var = T();
|
||||||
|
</pre>
|
||||||
|
But as mentioned before, this form suffers from various compiler issues.
|
||||||
|
The template <code>value_initialized</code> offers a workaround:
|
||||||
|
<pre>
|
||||||
|
T var = get( value_initialized<T>() );
|
||||||
|
</pre>
|
||||||
|
Unfortunately both forms repeat the type name, which
|
||||||
|
is rather short now (<code>T</code>), but could of course be
|
||||||
|
more like <code>Namespace::Template<Arg>::Type</code>.
|
||||||
|
Instead, one could use <code>initialized_value</code> as follows:
|
||||||
|
<pre>
|
||||||
|
T var = initialized_value();
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h3><a name="references">References</a></h3>
|
<h3><a name="references">References</a></h3>
|
||||||
[1] The C++ Standard, ISO/IEC 14882:98 <br>
|
[1] Bjarne Stroustrup, Gabriel Dos Reis, and J. Stephen Adamczyk wrote
|
||||||
[2] Plain Old Data
|
various papers, proposing to extend the support for brace-enclosed <em>initializer lists</em>
|
||||||
|
in the next version of C++.
|
||||||
|
This would allow a variable <code>var</code> of any DefaultConstructible type
|
||||||
|
<code>T</code> to be <em>value-initialized</em> by doing <code>T var = {}</code>.
|
||||||
|
The papers are listed at Bjarne's web page,
|
||||||
|
<a href="http://www.research.att.com/~bs/WG21.html">My C++ Standards committee papers</a> <br>
|
||||||
|
[2] Scott Meyers, Effective C++, Third Edition, item 6,
|
||||||
|
<em>Explicitly disallow the use of compiler-generated functions you do not want</em>,
|
||||||
|
<a href="http://www.aristeia.com/books.html">Scott Meyers: Books and CDs</a> <br>
|
||||||
|
[3] The C++ Standard, Second edition (2003), ISO/IEC 14882:2003 <br>
|
||||||
|
[4] POD stands for "Plain Old Data"
|
||||||
|
|
||||||
<h3><a name="acknowledgements"></a>Acknowledgements</h3>
|
<h3><a name="acknowledgements"></a>Acknowledgements</h3>
|
||||||
value_initialized was developed by Fernando Cacciola, with help and
|
value_initialized was developed by Fernando Cacciola, with help and
|
||||||
suggestions from David Abrahams and Darin Adler.<br>
|
suggestions from David Abrahams and Darin Adler.<br>
|
||||||
Special thanks to Bj<EFBFBD>rn Karlsson who carefully edited and completed this documentation.
|
Special thanks to Björn Karlsson who carefully edited and completed this documentation.
|
||||||
<pre> </pre>
|
|
||||||
|
<p>value_initialized was reimplemented by Fernando Cacciola and Niels Dekker
|
||||||
<hr>
|
for Boost release version 1.35 (2008), offering a workaround to various compiler issues.
|
||||||
<p>Revised 19 September 2002</p>
|
</p>
|
||||||
|
|
||||||
<p>© Copyright boost.org 2002. Permission to copy, use, modify, sell
|
|
||||||
and distribute this document is granted provided this copyright notice appears
|
|
||||||
in all copies. This document is provided "as is" without express or implied
|
|
||||||
warranty, and with no claim as to its suitability for any purpose.</p>
|
|
||||||
|
|
||||||
<p>Developed by <a href="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</a>,
|
<p>Developed by <a href="mailto:fernando_cacciola@hotmail.com">Fernando Cacciola</a>,
|
||||||
the latest version of this file can be found at <a
|
the latest version of this file can be found at <a
|
||||||
href="http://www.boost.org">www.boost.org</a>, and the boost discussion list
|
href="http://www.boost.org">www.boost.org</a>.
|
||||||
at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<p>Revised 16 January 2008</p>
|
||||||
|
|
||||||
|
<p>© Copyright Fernando Cacciola, 2002, 2008.</p>
|
||||||
|
|
||||||
|
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||||
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,4 +1,4 @@
|
|||||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
// Copyright 2002-2008, Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -6,12 +6,15 @@
|
|||||||
//
|
//
|
||||||
// Test program for "boost/utility/value_init.hpp"
|
// Test program for "boost/utility/value_init.hpp"
|
||||||
//
|
//
|
||||||
// Initial: 21 Agu 2002
|
// 21 Ago 2002 (Created) Fernando Cacciola
|
||||||
|
// 19 Jan 2008 (Added tests regarding compiler issues and initialized_value) Fernando Cacciola, Niels Dekker
|
||||||
|
|
||||||
|
#include <cstring> // For memcmp.
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "boost/utility/value_init.hpp"
|
#include "boost/utility/value_init.hpp"
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
@ -49,7 +52,7 @@ struct NonPODBase
|
|||||||
struct NonPOD : NonPODBase
|
struct NonPOD : NonPODBase
|
||||||
{
|
{
|
||||||
NonPOD () : id() {}
|
NonPOD () : id() {}
|
||||||
NonPOD ( std::string const& id_) : id(id_) {}
|
explicit NonPOD ( std::string const& id_) : id(id_) {}
|
||||||
|
|
||||||
friend std::ostream& operator << ( std::ostream& os, NonPOD const& npod )
|
friend std::ostream& operator << ( std::ostream& os, NonPOD const& npod )
|
||||||
{ return os << '(' << npod.id << ')' ; }
|
{ return os << '(' << npod.id << ')' ; }
|
||||||
@ -60,12 +63,165 @@ struct NonPOD : NonPODBase
|
|||||||
std::string id ;
|
std::string id ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
template<class T>
|
//
|
||||||
void test ( T const& y, T const& z )
|
// Sample aggregate POD struct type
|
||||||
|
// Some compilers do not correctly value-initialize such a struct, for example:
|
||||||
|
// Borland C++ Report #51854, "Value-initialization: POD struct should be zero-initialized "
|
||||||
|
// http://qc.codegear.com/wc/qcmain.aspx?d=51854
|
||||||
|
//
|
||||||
|
struct AggregatePODStruct
|
||||||
{
|
{
|
||||||
|
float f;
|
||||||
|
char c;
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator == ( AggregatePODStruct const& lhs, AggregatePODStruct const& rhs )
|
||||||
|
{ return lhs.f == rhs.f && lhs.c == rhs.c && lhs.i == rhs.i ; }
|
||||||
|
|
||||||
|
//
|
||||||
|
// An aggregate struct that contains an std::string and an int.
|
||||||
|
// Pavel Kuznetsov (MetaCommunications Engineering) used a struct like
|
||||||
|
// this to reproduce the Microsoft Visual C++ compiler bug, reported as
|
||||||
|
// Feedback ID 100744, "Value-initialization in new-expression"
|
||||||
|
// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
|
||||||
|
//
|
||||||
|
struct StringAndInt
|
||||||
|
{
|
||||||
|
std::string s;
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator == ( StringAndInt const& lhs, StringAndInt const& rhs )
|
||||||
|
{ return lhs.s == rhs.s && lhs.i == rhs.i ; }
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// A struct that has an explicit (user defined) destructor.
|
||||||
|
// Some compilers do not correctly value-initialize such a struct, for example:
|
||||||
|
// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression"
|
||||||
|
// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
|
||||||
|
//
|
||||||
|
struct StructWithDestructor
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
~StructWithDestructor() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator == ( StructWithDestructor const& lhs, StructWithDestructor const& rhs )
|
||||||
|
{ return lhs.i == rhs.i ; }
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// A struct that has a virtual function.
|
||||||
|
// Some compilers do not correctly value-initialize such a struct either, for example:
|
||||||
|
// Microsoft Visual C++, Feedback ID 100744, "Value-initialization in new-expression"
|
||||||
|
// https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
|
||||||
|
//
|
||||||
|
struct StructWithVirtualFunction
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
virtual void VirtualFunction();
|
||||||
|
};
|
||||||
|
|
||||||
|
void StructWithVirtualFunction::VirtualFunction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == ( StructWithVirtualFunction const& lhs, StructWithVirtualFunction const& rhs )
|
||||||
|
{ return lhs.i == rhs.i ; }
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// A struct that is derived from an aggregate POD struct.
|
||||||
|
// Some compilers do not correctly value-initialize such a struct, for example:
|
||||||
|
// GCC Bugzilla Bug 30111, "Value-initialization of POD base class doesn't initialize members",
|
||||||
|
// reported by Jonathan Wakely, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30111
|
||||||
|
//
|
||||||
|
struct DerivedFromAggregatePODStruct : AggregatePODStruct
|
||||||
|
{
|
||||||
|
DerivedFromAggregatePODStruct() : AggregatePODStruct() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// A struct that wraps an aggregate POD struct as data member.
|
||||||
|
//
|
||||||
|
struct AggregatePODStructWrapper
|
||||||
|
{
|
||||||
|
AggregatePODStructWrapper() : dataMember() {}
|
||||||
|
AggregatePODStruct dataMember;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator == ( AggregatePODStructWrapper const& lhs, AggregatePODStructWrapper const& rhs )
|
||||||
|
{ return lhs.dataMember == rhs.dataMember ; }
|
||||||
|
|
||||||
|
typedef unsigned char ArrayOfBytes[256];
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// A struct that allows testing whether the appropriate copy functions are called.
|
||||||
|
//
|
||||||
|
struct CopyFunctionCallTester
|
||||||
|
{
|
||||||
|
bool is_copy_constructed;
|
||||||
|
bool is_assignment_called;
|
||||||
|
|
||||||
|
CopyFunctionCallTester()
|
||||||
|
: is_copy_constructed(false), is_assignment_called(false) {}
|
||||||
|
|
||||||
|
CopyFunctionCallTester(const CopyFunctionCallTester & )
|
||||||
|
: is_copy_constructed(true), is_assignment_called(false) {}
|
||||||
|
|
||||||
|
CopyFunctionCallTester & operator=(const CopyFunctionCallTester & )
|
||||||
|
{
|
||||||
|
is_assignment_called = true ;
|
||||||
|
return *this ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void check_initialized_value ( T const& y )
|
||||||
|
{
|
||||||
|
T initializedValue = boost::initialized_value() ;
|
||||||
|
BOOST_CHECK ( y == initializedValue ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#if __BORLANDC__ == 0x582
|
||||||
|
void check_initialized_value( NonPOD const& )
|
||||||
|
{
|
||||||
|
// The initialized_value check is skipped for Borland 5.82
|
||||||
|
// and this type (NonPOD), because the following statement
|
||||||
|
// won't compile on this particular compiler version:
|
||||||
|
// NonPOD initializedValue = boost::initialized_value() ;
|
||||||
|
//
|
||||||
|
// This is caused by a compiler bug, that is fixed with a newer version
|
||||||
|
// of the Borland compiler. The Release Notes for Delphi(R) 2007 for
|
||||||
|
// Win32(R) and C++Builder(R) 2007 (http://dn.codegear.com/article/36575)
|
||||||
|
// say about similar statements:
|
||||||
|
// both of these statements now compile but under 5.82 got the error:
|
||||||
|
// Error E2015: Ambiguity between 'V::V(const A &)' and 'V::V(const V &)'
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// This test function tests boost::value_initialized<T> for a specific type T.
|
||||||
|
// The first argument (y) is assumed have the value of a value-initialized object.
|
||||||
|
// Returns true on success.
|
||||||
|
//
|
||||||
|
template<class T>
|
||||||
|
bool test ( T const& y, T const& z )
|
||||||
|
{
|
||||||
|
const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter();
|
||||||
|
|
||||||
|
check_initialized_value(y);
|
||||||
|
|
||||||
boost::value_initialized<T> x ;
|
boost::value_initialized<T> x ;
|
||||||
BOOST_CHECK ( y == x ) ;
|
BOOST_CHECK ( y == x ) ;
|
||||||
BOOST_CHECK ( y == boost::get(x) ) ;
|
BOOST_CHECK ( y == boost::get(x) ) ;
|
||||||
|
|
||||||
static_cast<T&>(x) = z ;
|
static_cast<T&>(x) = z ;
|
||||||
boost::get(x) = z ;
|
boost::get(x) = z ;
|
||||||
BOOST_CHECK ( x == z ) ;
|
BOOST_CHECK ( x == z ) ;
|
||||||
@ -77,6 +233,16 @@ void test ( T const& y, T const& z )
|
|||||||
x_c_ref = z ;
|
x_c_ref = z ;
|
||||||
BOOST_CHECK ( x_c == z ) ;
|
BOOST_CHECK ( x_c == z ) ;
|
||||||
|
|
||||||
|
boost::value_initialized<T> const copy1 = x;
|
||||||
|
BOOST_CHECK ( boost::get(copy1) == boost::get(x) ) ;
|
||||||
|
|
||||||
|
boost::value_initialized<T> copy2;
|
||||||
|
copy2 = x;
|
||||||
|
BOOST_CHECK ( boost::get(copy2) == boost::get(x) ) ;
|
||||||
|
|
||||||
|
boost::shared_ptr<boost::value_initialized<T> > ptr( new boost::value_initialized<T> );
|
||||||
|
BOOST_CHECK ( y == *ptr ) ;
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||||
boost::value_initialized<T const> cx ;
|
boost::value_initialized<T const> cx ;
|
||||||
BOOST_CHECK ( y == cx ) ;
|
BOOST_CHECK ( y == cx ) ;
|
||||||
@ -86,14 +252,71 @@ void test ( T const& y, T const& z )
|
|||||||
BOOST_CHECK ( y == cx_c ) ;
|
BOOST_CHECK ( y == cx_c ) ;
|
||||||
BOOST_CHECK ( y == boost::get(cx_c) ) ;
|
BOOST_CHECK ( y == boost::get(cx_c) ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return boost::minimal_test::errors_counter() == counter_before_test ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_main(int, char **)
|
int test_main(int, char **)
|
||||||
{
|
{
|
||||||
test( 0,1234 ) ;
|
BOOST_CHECK ( test( 0,1234 ) ) ;
|
||||||
test( 0.0,12.34 ) ;
|
BOOST_CHECK ( test( 0.0,12.34 ) ) ;
|
||||||
test( POD(0,0,0.0), POD('a',1234,56.78) ) ;
|
BOOST_CHECK ( test( POD(0,0,0.0), POD('a',1234,56.78) ) ) ;
|
||||||
test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ;
|
BOOST_CHECK ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ;
|
||||||
|
|
||||||
|
NonPOD NonPOD_object( std::string("NonPOD_object") );
|
||||||
|
BOOST_CHECK ( test<NonPOD *>( 0, &NonPOD_object ) ) ;
|
||||||
|
|
||||||
|
AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 };
|
||||||
|
AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 };
|
||||||
|
BOOST_CHECK ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) );
|
||||||
|
|
||||||
|
StringAndInt stringAndInt0;
|
||||||
|
StringAndInt stringAndInt1;
|
||||||
|
stringAndInt0.i = 0;
|
||||||
|
stringAndInt1.i = 1;
|
||||||
|
stringAndInt1.s = std::string("1");
|
||||||
|
BOOST_CHECK ( test(stringAndInt0, stringAndInt1) );
|
||||||
|
|
||||||
|
StructWithDestructor structWithDestructor0;
|
||||||
|
StructWithDestructor structWithDestructor1;
|
||||||
|
structWithDestructor0.i = 0;
|
||||||
|
structWithDestructor1.i = 1;
|
||||||
|
BOOST_CHECK ( test(structWithDestructor0, structWithDestructor1) );
|
||||||
|
|
||||||
|
StructWithVirtualFunction structWithVirtualFunction0;
|
||||||
|
StructWithVirtualFunction structWithVirtualFunction1;
|
||||||
|
structWithVirtualFunction0.i = 0;
|
||||||
|
structWithVirtualFunction1.i = 1;
|
||||||
|
BOOST_CHECK ( test(structWithVirtualFunction0, structWithVirtualFunction1) );
|
||||||
|
|
||||||
|
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct0;
|
||||||
|
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct1;
|
||||||
|
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct0) = zeroInitializedAggregatePODStruct;
|
||||||
|
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct1) = nonZeroInitializedAggregatePODStruct;
|
||||||
|
BOOST_CHECK ( test(derivedFromAggregatePODStruct0, derivedFromAggregatePODStruct1) );
|
||||||
|
|
||||||
|
AggregatePODStructWrapper aggregatePODStructWrapper0;
|
||||||
|
AggregatePODStructWrapper aggregatePODStructWrapper1;
|
||||||
|
aggregatePODStructWrapper0.dataMember = zeroInitializedAggregatePODStruct;
|
||||||
|
aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct;
|
||||||
|
BOOST_CHECK ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) );
|
||||||
|
|
||||||
|
ArrayOfBytes zeroInitializedArrayOfBytes = { 0 };
|
||||||
|
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes;
|
||||||
|
BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0);
|
||||||
|
|
||||||
|
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester1;
|
||||||
|
BOOST_CHECK ( ! get(copyFunctionCallTester1).is_copy_constructed);
|
||||||
|
BOOST_CHECK ( ! get(copyFunctionCallTester1).is_assignment_called);
|
||||||
|
|
||||||
|
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester2 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
|
||||||
|
BOOST_CHECK ( get(copyFunctionCallTester2).is_copy_constructed);
|
||||||
|
BOOST_CHECK ( ! get(copyFunctionCallTester2).is_assignment_called);
|
||||||
|
|
||||||
|
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester3;
|
||||||
|
copyFunctionCallTester3 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
|
||||||
|
BOOST_CHECK ( ! get(copyFunctionCallTester3).is_copy_constructed);
|
||||||
|
BOOST_CHECK ( get(copyFunctionCallTester3).is_assignment_called);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -101,7 +324,3 @@ int test_main(int, char **)
|
|||||||
|
|
||||||
unsigned int expected_failures = 0;
|
unsigned int expected_failures = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
// Copyright 2002, Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
// Copyright 2002, Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// (C) 2002, Fernando Luis Cacciola Carballal.
|
// Copyright 2002, Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
126
verify_test.cpp
Normal file
126
verify_test.cpp
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
//
|
||||||
|
// verify_test.cpp - a test for BOOST_VERIFY
|
||||||
|
//
|
||||||
|
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||||
|
// Copyright (c) 2007 Peter Dimov
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
|
int f( int & x )
|
||||||
|
{
|
||||||
|
return ++x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_default()
|
||||||
|
{
|
||||||
|
int x = 1;
|
||||||
|
|
||||||
|
BOOST_VERIFY( 1 );
|
||||||
|
BOOST_VERIFY( x == 1 );
|
||||||
|
BOOST_VERIFY( ++x );
|
||||||
|
BOOST_VERIFY( f(x) );
|
||||||
|
BOOST_VERIFY( &x );
|
||||||
|
|
||||||
|
BOOST_TEST( x == 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BOOST_DISABLE_ASSERTS
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
|
void test_disabled()
|
||||||
|
{
|
||||||
|
int x = 1;
|
||||||
|
|
||||||
|
BOOST_VERIFY( 1 );
|
||||||
|
BOOST_VERIFY( x == 1 );
|
||||||
|
BOOST_VERIFY( ++x );
|
||||||
|
BOOST_VERIFY( f(x) );
|
||||||
|
BOOST_VERIFY( &x );
|
||||||
|
|
||||||
|
BOOST_TEST( x == 3 );
|
||||||
|
|
||||||
|
BOOST_VERIFY( 0 );
|
||||||
|
BOOST_VERIFY( !x );
|
||||||
|
BOOST_VERIFY( x == 0 );
|
||||||
|
BOOST_VERIFY( !++x );
|
||||||
|
BOOST_VERIFY( !f(x) );
|
||||||
|
|
||||||
|
BOOST_TEST( x == 5 );
|
||||||
|
|
||||||
|
void * p = 0;
|
||||||
|
BOOST_VERIFY( p );
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef BOOST_DISABLE_ASSERTS
|
||||||
|
|
||||||
|
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
int handler_invoked = 0;
|
||||||
|
|
||||||
|
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||||
|
using std::printf;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line);
|
||||||
|
++handler_invoked;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
static bool f()
|
||||||
|
{
|
||||||
|
BOOST_VERIFY( 0 );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void test_handler()
|
||||||
|
{
|
||||||
|
int x = 1;
|
||||||
|
|
||||||
|
BOOST_VERIFY( 1 );
|
||||||
|
BOOST_VERIFY( x == 1 );
|
||||||
|
BOOST_VERIFY( ++x );
|
||||||
|
BOOST_VERIFY( f(x) );
|
||||||
|
BOOST_VERIFY( &x );
|
||||||
|
|
||||||
|
BOOST_TEST( x == 3 );
|
||||||
|
|
||||||
|
BOOST_VERIFY( 0 );
|
||||||
|
BOOST_VERIFY( !x );
|
||||||
|
BOOST_VERIFY( x == 0 );
|
||||||
|
BOOST_VERIFY( !++x );
|
||||||
|
BOOST_VERIFY( !f(x) );
|
||||||
|
|
||||||
|
BOOST_TEST( x == 5 );
|
||||||
|
|
||||||
|
void * p = 0;
|
||||||
|
BOOST_VERIFY( p );
|
||||||
|
|
||||||
|
BOOST_VERIFY( X::f() );
|
||||||
|
|
||||||
|
BOOST_TEST( handler_invoked == 8 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test_default();
|
||||||
|
test_disabled();
|
||||||
|
test_handler();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user