mirror of
https://github.com/boostorg/utility.git
synced 2025-10-14 01:25:20 +02:00
Compare commits
169 Commits
boost-1.44
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
|
6a93732f6b | ||
|
58bb88d4bd | ||
|
11d50ecb9f | ||
|
636283d7c2 | ||
|
1df0bf80bc | ||
|
71e78a0081 | ||
|
f7e4b0e399 | ||
|
fb1d2effef | ||
|
94b91e8c92 | ||
|
a4b8043e68 | ||
|
b4a08fc80e | ||
|
9da96d9737 | ||
|
a991936c96 | ||
|
6239e685a2 | ||
|
e601fcb9c9 | ||
|
f29a5db08e | ||
|
22743ee125 | ||
|
e3c982287a | ||
|
82e1111bb8 | ||
|
9339b32178 | ||
|
3770221507 | ||
|
e6cb3a77ee | ||
|
bbccfbbab4 | ||
|
74a6a693d3 | ||
|
bf713ad47a | ||
|
76b17c497b | ||
|
3de5974419 | ||
|
7eb1536590 | ||
|
9339431e03 | ||
|
f2349baf7d | ||
|
8745ca628a | ||
|
ba61e9d796 | ||
|
afe74fffbc | ||
|
09a0137016 | ||
|
a1d3ec6c53 | ||
|
5be3004e6c | ||
|
d387905150 | ||
|
b514e40733 | ||
|
b02677375f | ||
|
61a6015b5a | ||
|
682032a340 | ||
|
67afd7e315 | ||
|
75cf20cace | ||
|
91385ac627 | ||
|
61e9b93f7c | ||
|
d97b303777 | ||
|
3900e8ece4 | ||
|
e27fc4a853 | ||
|
f7aa9a8935 | ||
|
0af1959b30 | ||
|
5f0cf4f5de | ||
|
0282c8a141 | ||
|
6725719bd9 | ||
|
97e11b024e | ||
|
118e473a3d | ||
|
d4b6193f94 | ||
|
d420c98a53 | ||
|
d153ab4daa | ||
|
561f83b991 | ||
|
57124703f9 | ||
|
53f6d10652 | ||
|
ebe853ff2f | ||
|
487a5c1ea5 | ||
|
c4338b1ce8 | ||
|
ddd8a58ae0 | ||
|
28061ba3a8 | ||
|
5d53e3f837 | ||
|
e86ce1cb1f | ||
|
f15c96ffb0 | ||
|
a487f72329 | ||
|
9f08ed6de0 | ||
|
2077d0dace | ||
|
7f2348269b | ||
|
6b6e1c3252 | ||
|
55f303baec | ||
|
d264005c11 | ||
|
2cde009bb1 | ||
|
7bfb7c8a61 | ||
|
5c42397244 | ||
|
782c132d99 | ||
|
36899afa3f | ||
|
7e3e326faf | ||
|
7019e18149 | ||
|
49faf23433 | ||
|
62836f2928 | ||
|
1ecf3ceb74 | ||
|
2aa48414c9 | ||
|
d215f2176c | ||
|
c286d62223 | ||
|
3fd0ea6e75 | ||
|
b050431638 | ||
|
b311fcefb2 | ||
|
899c92420c | ||
|
64a0e0cb20 | ||
|
ece6992540 | ||
|
6098304ea8 | ||
|
28fff2d821 | ||
|
0ce3885d59 | ||
|
1823481d96 | ||
|
cce5d77d2b | ||
|
3c5c2bc107 | ||
|
177ee78bbb | ||
|
f1ec0c4d04 | ||
|
4a564744fe | ||
|
67f3ca090a | ||
|
8efae71f4a | ||
|
ad0bcf4a00 | ||
|
f1c86c35c4 | ||
|
a5b85eda07 | ||
|
bafe37fdab | ||
|
be50b95508 | ||
|
96d573d6ca | ||
|
2412b864d6 | ||
|
94865eabe6 | ||
|
50268d1b29 | ||
|
ad9108c1dc | ||
|
691e4b6c34 | ||
|
28596e678d | ||
|
1beca24dd8 | ||
|
721764937f | ||
|
a511007d0f | ||
|
8ce58b1675 | ||
|
9ed68b8321 | ||
|
79bbf71d0d | ||
|
ac93de7c1b | ||
|
d731b8e1c5 | ||
|
ac1567b3fc | ||
|
c1fd670480 | ||
|
01274cf6ac | ||
|
8080673977 | ||
|
a470b591fb | ||
|
e1a63495b6 | ||
|
7300ac83f1 | ||
|
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 |
68
doc/Jamfile.v2
Normal file
68
doc/Jamfile.v2
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
# Copyright John Maddock 2005. Use, modification, and distribution are
|
||||||
|
# subject to 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)
|
||||||
|
|
||||||
|
project : requirements
|
||||||
|
# Path for links to Boost:
|
||||||
|
<xsl:param>boost.root=../../../..
|
||||||
|
|
||||||
|
# Some general style settings:
|
||||||
|
<xsl:param>table.footnote.number.format=1
|
||||||
|
<xsl:param>footnote.number.format=1
|
||||||
|
|
||||||
|
# HTML options first:
|
||||||
|
# Use graphics not text for navigation:
|
||||||
|
<xsl:param>navig.graphics=1
|
||||||
|
# PDF Options:
|
||||||
|
# TOC Generation: this is needed for FOP-0.9 and later:
|
||||||
|
<xsl:param>fop1.extensions=0
|
||||||
|
<xsl:param>xep.extensions=1
|
||||||
|
# TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
|
||||||
|
<xsl:param>fop.extensions=0
|
||||||
|
# No indent on body text:
|
||||||
|
<xsl:param>body.start.indent=0pt
|
||||||
|
# Margin size:
|
||||||
|
<xsl:param>page.margin.inner=0.5in
|
||||||
|
# Margin size:
|
||||||
|
<xsl:param>page.margin.outer=0.5in
|
||||||
|
# Paper type = A4
|
||||||
|
<xsl:param>paper.type=A4
|
||||||
|
# Yes, we want graphics for admonishments:
|
||||||
|
<xsl:param>admon.graphics=1
|
||||||
|
# Set this one for PDF generation *only*:
|
||||||
|
# default pnd graphics are awful in PDF form,
|
||||||
|
# better use SVG's instead:
|
||||||
|
<format>pdf:<xsl:param>admon.graphics.extension=".svg"
|
||||||
|
<format>pdf:<xsl:param>admon.graphics.path=$(boost-images)/
|
||||||
|
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/utility/doc/html
|
||||||
|
;
|
||||||
|
|
||||||
|
using quickbook ;
|
||||||
|
|
||||||
|
path-constant boost-images : ../../../doc/src/images ;
|
||||||
|
|
||||||
|
xml declval : declval.qbk ;
|
||||||
|
boostbook standalone
|
||||||
|
:
|
||||||
|
declval
|
||||||
|
:
|
||||||
|
# File name of HTML output:
|
||||||
|
<xsl:param>root.filename=declval
|
||||||
|
# How far down we chunk nested sections, basically all of them:
|
||||||
|
<xsl:param>chunk.section.depth=0
|
||||||
|
# Don't put the first section on the same page as the TOC:
|
||||||
|
<xsl:param>chunk.first.sections=0
|
||||||
|
# How far down sections get TOC's
|
||||||
|
<xsl:param>toc.section.depth=1
|
||||||
|
# Max depth in each TOC:
|
||||||
|
<xsl:param>toc.max.depth=1
|
||||||
|
# How far down we go with TOC's
|
||||||
|
<xsl:param>generate.section.toc.level=1
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
104
doc/declval.qbk
Normal file
104
doc/declval.qbk
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
[/
|
||||||
|
/ Copyright (c) 2008 Howard Hinnant
|
||||||
|
/ Copyright (c) 2008 Beman Dawes
|
||||||
|
/ Copyright (c) 2009-20010 Vicente J. Botet Escriba
|
||||||
|
/
|
||||||
|
/ 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)
|
||||||
|
/]
|
||||||
|
|
||||||
|
[article Declval
|
||||||
|
[quickbook 1.5]
|
||||||
|
[authors [Hinnant, Howard]]
|
||||||
|
[authors [Dawes, Beman]]
|
||||||
|
[authors [Botet Escriba, Vicente J.]]
|
||||||
|
[copyright 2008 Howard Hinnant]
|
||||||
|
[copyright 2008 Beman Dawes]
|
||||||
|
[copyright 2009-2010 Vicente J. Botet Escriba]
|
||||||
|
[license
|
||||||
|
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])
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
[/===============]
|
||||||
|
[section Overview]
|
||||||
|
[/===============]
|
||||||
|
|
||||||
|
The motivation for `declval` was introduced in [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2958.html#Value N2958:
|
||||||
|
Moving Swap Forward]. Here follows a rewording of this chapter.
|
||||||
|
|
||||||
|
With the provision of decltype, late-specified return types, and default template-arguments for function templates a
|
||||||
|
new generation of SFINAE patterns will emerge to at least partially compensate the lack of concepts on the C++0x timescale.
|
||||||
|
Using this technique, it is sometimes necessary to obtain an object of a known type in a non-using context, e.g. given the declaration
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T&& declval(); // not used
|
||||||
|
|
||||||
|
as part of the function template declaration
|
||||||
|
|
||||||
|
template<class To, class From>
|
||||||
|
decltype(static_cast<To>(declval<From>())) convert(From&&);
|
||||||
|
|
||||||
|
or as part of a class template definition
|
||||||
|
|
||||||
|
template<class> class result_of;
|
||||||
|
|
||||||
|
template<class Fn, class... ArgTypes>
|
||||||
|
struct result_of<Fn(ArgTypes...)>
|
||||||
|
{
|
||||||
|
typedef decltype(declval<Fn>()(declval<ArgTypes>()...)) type;
|
||||||
|
};
|
||||||
|
|
||||||
|
The role of the function template declval() is a transformation of a type T into a value without using or evaluating this function.
|
||||||
|
The name is supposed to direct the reader's attention to the fact that the expression `declval<T>()` is an lvalue if and only if
|
||||||
|
T is an lvalue-reference, otherwise an rvalue. To extend the domain of this function we can do a bit better by changing its declaration to
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::add_rvalue_reference<T>::type declval(); // not used
|
||||||
|
|
||||||
|
which ensures that we can also use cv void as template parameter. The careful reader might have noticed that `declval()`
|
||||||
|
already exists under the name create() as part of the definition of the semantics of the type trait is_convertible in the C==0x standard.
|
||||||
|
|
||||||
|
The provision of a new library component that allows the production of values in unevaluated expressions is considered as
|
||||||
|
important to realize constrained templates in C++0x where concepts are not available.
|
||||||
|
This extremely light-weight function is expected to be part of the daily tool-box of the C++0x programmer.
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
|
||||||
|
[/=================]
|
||||||
|
[section:reference Reference ]
|
||||||
|
[/=================]
|
||||||
|
|
||||||
|
`#include <boost/utility/declval.hpp>`
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
typename add_rvalue_reference<T>::type declval(); //noexcept; // as unevaluated operand
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
The library provides the function template declval to simplify the definition of expressions which occur as unevaluated operands.
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
typename add_rvalue_reference<T>::type declval();
|
||||||
|
|
||||||
|
[*Remarks:] If this function is used, the program is ill-formed.
|
||||||
|
|
||||||
|
[*Remarks:] The template parameter T of declval may be an incomplete type.
|
||||||
|
|
||||||
|
[*Example:]
|
||||||
|
|
||||||
|
template <class To, class From>
|
||||||
|
decltype(static_cast<To>(declval<From>())) convert(From&&);
|
||||||
|
|
||||||
|
Declares a function template convert which only participats in overloading if the type From can be explicitly converted to type To.
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
|
||||||
|
|
163
doc/html/declval.html
Normal file
163
doc/html/declval.html
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||||
|
<title>Declval</title>
|
||||||
|
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
|
||||||
|
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||||
|
<link rel="home" href="declval.html" title="Declval">
|
||||||
|
</head>
|
||||||
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
|
<table cellpadding="2" width="100%"><tr>
|
||||||
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
|
||||||
|
<td align="center"><a href="../../../../index.html">Home</a></td>
|
||||||
|
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
|
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||||
|
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||||
|
<td align="center"><a href="../../../../more/index.htm">More</a></td>
|
||||||
|
</tr></table>
|
||||||
|
<hr>
|
||||||
|
<div class="spirit-nav"></div>
|
||||||
|
<div class="article" lang="en">
|
||||||
|
<div class="titlepage">
|
||||||
|
<div>
|
||||||
|
<div><h2 class="title">
|
||||||
|
<a name="declval"></a>Declval</h2></div>
|
||||||
|
<div><div class="authorgroup">
|
||||||
|
<div class="author"><h3 class="author">
|
||||||
|
<span class="firstname">Howard</span> <span class="surname">Hinnant</span>
|
||||||
|
</h3></div>
|
||||||
|
<div class="author"><h3 class="author">
|
||||||
|
<span class="firstname">Beman</span> <span class="surname">Dawes</span>
|
||||||
|
</h3></div>
|
||||||
|
<div class="author"><h3 class="author">
|
||||||
|
<span class="firstname">Vicente J.</span> <span class="surname">Botet Escriba</span>
|
||||||
|
</h3></div>
|
||||||
|
</div></div>
|
||||||
|
<div><p class="copyright">Copyright © 2008 Howard Hinnant</p></div>
|
||||||
|
<div><p class="copyright">Copyright © 2008 Beman Dawes</p></div>
|
||||||
|
<div><p class="copyright">Copyright © 2009 -2010 Vicente J. Botet Escriba</p></div>
|
||||||
|
<div><div class="legalnotice">
|
||||||
|
<a name="id879409"></a><p>
|
||||||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
|
</p>
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
<div class="toc">
|
||||||
|
<p><b>Table of Contents</b></p>
|
||||||
|
<dl>
|
||||||
|
<dt><span class="section"><a href="declval.html#declval.overview">Overview</a></span></dt>
|
||||||
|
<dt><span class="section"><a href="declval.html#declval.reference"> Reference </a></span></dt>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<div class="section" lang="en">
|
||||||
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
|
<a name="declval.overview"></a><a class="link" href="declval.html#declval.overview" title="Overview">Overview</a>
|
||||||
|
</h2></div></div></div>
|
||||||
|
<p>
|
||||||
|
The motivation for <code class="computeroutput"><span class="identifier">declval</span></code>
|
||||||
|
was introduced in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2958.html#Value" target="_top">N2958:
|
||||||
|
Moving Swap Forward</a>. Here follows a rewording of this chapter.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
With the provision of decltype, late-specified return types, and default template-arguments
|
||||||
|
for function templates a new generation of SFINAE patterns will emerge to at
|
||||||
|
least partially compensate the lack of concepts on the C++0x timescale. Using
|
||||||
|
this technique, it is sometimes necessary to obtain an object of a known type
|
||||||
|
in a non-using context, e.g. given the declaration
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||||
|
<span class="identifier">T</span><span class="special">&&</span> <span class="identifier">declval</span><span class="special">();</span> <span class="comment">// not used
|
||||||
|
</span></pre>
|
||||||
|
<p>
|
||||||
|
as part of the function template declaration
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">To</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">From</span><span class="special">></span>
|
||||||
|
<span class="identifier">decltype</span><span class="special">(</span><span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">To</span><span class="special">>(</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">From</span><span class="special">>()))</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">From</span><span class="special">&&);</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
or as part of a class template definition
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">></span> <span class="keyword">class</span> <span class="identifier">result_of</span><span class="special">;</span>
|
||||||
|
|
||||||
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> <span class="identifier">ArgTypes</span><span class="special">></span>
|
||||||
|
<span class="keyword">struct</span> <span class="identifier">result_of</span><span class="special"><</span><span class="identifier">Fn</span><span class="special">(</span><span class="identifier">ArgTypes</span><span class="special">...)></span>
|
||||||
|
<span class="special">{</span>
|
||||||
|
<span class="keyword">typedef</span> <span class="identifier">decltype</span><span class="special">(</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">Fn</span><span class="special">>()(</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">ArgTypes</span><span class="special">>()...))</span> <span class="identifier">type</span><span class="special">;</span>
|
||||||
|
<span class="special">};</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
The role of the function template declval() is a transformation of a type T
|
||||||
|
into a value without using or evaluating this function. The name is supposed
|
||||||
|
to direct the reader's attention to the fact that the expression <code class="computeroutput"><span class="identifier">declval</span><span class="special"><</span><span class="identifier">T</span><span class="special">>()</span></code> is
|
||||||
|
an lvalue if and only if T is an lvalue-reference, otherwise an rvalue. To
|
||||||
|
extend the domain of this function we can do a bit better by changing its declaration
|
||||||
|
to
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||||
|
<span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">declval</span><span class="special">();</span> <span class="comment">// not used
|
||||||
|
</span></pre>
|
||||||
|
<p>
|
||||||
|
which ensures that we can also use cv void as template parameter. The careful
|
||||||
|
reader might have noticed that <code class="computeroutput"><span class="identifier">declval</span><span class="special">()</span></code> already exists under the name create() as
|
||||||
|
part of the definition of the semantics of the type trait is_convertible in
|
||||||
|
the C==0x standard.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The provision of a new library component that allows the production of values
|
||||||
|
in unevaluated expressions is considered as important to realize constrained
|
||||||
|
templates in C++0x where concepts are not available. This extremely light-weight
|
||||||
|
function is expected to be part of the daily tool-box of the C++0x programmer.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="section" lang="en">
|
||||||
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
|
<a name="declval.reference"></a><a class="link" href="declval.html#declval.reference" title="Reference"> Reference </a>
|
||||||
|
</h2></div></div></div>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">/</span><span class="identifier">declval</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
|
||||||
|
|
||||||
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||||
|
<span class="keyword">typename</span> <span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">declval</span><span class="special">();</span> <span class="comment">//noexcept; // as unevaluated operand
|
||||||
|
</span>
|
||||||
|
<span class="special">}</span> <span class="comment">// namespace boost
|
||||||
|
</span></pre>
|
||||||
|
<p>
|
||||||
|
The library provides the function template declval to simplify the definition
|
||||||
|
of expressions which occur as unevaluated operands.
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||||
|
<span class="keyword">typename</span> <span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">declval</span><span class="special">();</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
<span class="bold"><strong>Remarks:</strong></span> If this function is used, the program
|
||||||
|
is ill-formed.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span class="bold"><strong>Remarks:</strong></span> The template parameter T of declval
|
||||||
|
may be an incomplete type.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span class="bold"><strong>Example:</strong></span>
|
||||||
|
</p>
|
||||||
|
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">To</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">From</span><span class="special">></span>
|
||||||
|
<span class="identifier">decltype</span><span class="special">(</span><span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">To</span><span class="special">>(</span><span class="identifier">declval</span><span class="special"><</span><span class="identifier">From</span><span class="special">>()))</span> <span class="identifier">convert</span><span class="special">(</span><span class="identifier">From</span><span class="special">&&);</span>
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
Declares a function template convert which only participats in overloading
|
||||||
|
if the type From can be explicitly converted to type To.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
|
<td align="left"><p><small>Last revised: September 16, 2010 at 16:19:10 GMT</small></p></td>
|
||||||
|
<td align="right"><div class="copyright-footer"></div></td>
|
||||||
|
</tr></table>
|
||||||
|
<hr>
|
||||||
|
<div class="spirit-nav"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@@ -13,6 +13,12 @@
|
|||||||
// See http://www.boost.org/libs/utility/assert.html for documentation.
|
// See http://www.boost.org/libs/utility/assert.html for documentation.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Stop inspect complaining about use of 'assert':
|
||||||
|
//
|
||||||
|
// boostinspect:naassert_macro
|
||||||
|
//
|
||||||
|
|
||||||
#undef BOOST_ASSERT
|
#undef BOOST_ASSERT
|
||||||
|
|
||||||
#if defined(BOOST_DISABLE_ASSERTS)
|
#if defined(BOOST_DISABLE_ASSERTS)
|
||||||
|
@@ -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
|
||||||
|
// 16 Dec 10 Limit warning suppression for 4284 to older versions of VC++
|
||||||
|
// (Matthew Bradbury, fixes #4432)
|
||||||
// 07 Aug 08 Added "euclidean" spelling. (Daniel Frey)
|
// 07 Aug 08 Added "euclidean" spelling. (Daniel Frey)
|
||||||
// 03 Apr 08 Make sure "convertible to bool" is sufficient
|
// 03 Apr 08 Make sure "convertible to bool" is sufficient
|
||||||
// for T::operator<, etc. (Daniel Frey)
|
// for T::operator<, etc. (Daniel Frey)
|
||||||
@@ -88,7 +90,7 @@
|
|||||||
# pragma set woff 1234
|
# pragma set woff 1234
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1600)
|
||||||
# pragma warning( disable : 4284 ) // complaint about return type of
|
# pragma warning( disable : 4284 ) // complaint about return type of
|
||||||
#endif // operator-> not begin a UDT
|
#endif // operator-> not begin a UDT
|
||||||
|
|
||||||
|
44
include/boost/utility/declval.hpp
Normal file
44
include/boost/utility/declval.hpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// common_type.hpp ---------------------------------------------------------//
|
||||||
|
|
||||||
|
// Copyright 2010 Vicente J. Botet Escriba
|
||||||
|
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// See http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#ifndef BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
|
||||||
|
#define BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
#include <boost/type_traits/add_rvalue_reference.hpp>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
// //
|
||||||
|
// C++03 implementation of //
|
||||||
|
// Written by Vicente J. Botet Escriba //
|
||||||
|
//~ 20.3.4 Function template declval [declval]
|
||||||
|
//~ 1 The library provides the function template declval to simplify the definition of expressions which occur as
|
||||||
|
//~ unevaluated operands.
|
||||||
|
//~ 2 Remarks: If this function is used, the program is ill-formed.
|
||||||
|
//~ 3 Remarks: The template parameter T of declval may be an incomplete type.
|
||||||
|
//~ [ Example:
|
||||||
|
|
||||||
|
//~ template <class To, class From>
|
||||||
|
//~ decltype(static_cast<To>(declval<From>())) convert(From&&);
|
||||||
|
|
||||||
|
//~ declares a function template convert which only participats in overloading if the type From can be
|
||||||
|
//~ explicitly converted to type To. For another example see class template common_type (20.7.6.6). <20>end
|
||||||
|
//~ example ]
|
||||||
|
// //
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
typename add_rvalue_reference<T>::type declval(); //noexcept; // as unevaluated operand
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // BOOST_TYPE_TRAITS_EXT_DECLVAL__HPP
|
12
index.html
12
index.html
@@ -14,20 +14,28 @@
|
|||||||
<p>But that doesn't mean there isn't useful stuff here. Take a look:</p>
|
<p>But that doesn't mean there isn't useful stuff here. Take a look:</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>
|
<p>
|
||||||
|
<a href="utility.htm#addressof">addressof</a><br>
|
||||||
<a href="assert.html">assert</a><br>
|
<a href="assert.html">assert</a><br>
|
||||||
<a href="base_from_member.html">base_from_member</a><br>
|
<a href="base_from_member.html">base_from_member</a><br>
|
||||||
|
<a href="utility.htm#BOOST_BINARY">BOOST_BINARY</a><br>
|
||||||
<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="current_function.html">current_function</a><br>
|
||||||
<a href="enable_if.html">enable_if</a><br>
|
<a href="doc/html/declval.html">declval</a><br>
|
||||||
|
<a href="enable_if.html">enable_if</a><br>
|
||||||
|
<a href="in_place_factories.html">in_place_factory</a><br>
|
||||||
<a href="iterator_adaptors.htm">iterator_adaptors</a><br>
|
<a href="iterator_adaptors.htm">iterator_adaptors</a><br>
|
||||||
<a href="generator_iterator.htm">generator iterator adaptors</a><br>
|
<a href="generator_iterator.htm">generator iterator adaptors</a><br>
|
||||||
|
<a href="utility.htm#functions_next_prior">next/prior</a><br>
|
||||||
|
<a href="utility.htm#Class_noncopyable">noncopyable</a><br>
|
||||||
<a href="operators.htm">operators</a><br>
|
<a href="operators.htm">operators</a><br>
|
||||||
|
<a href="utility.htm#result_of">result_of</a><br>
|
||||||
<a href="swap.html">swap</a><br>
|
<a href="swap.html">swap</a><br>
|
||||||
<a href="throw_exception.html">throw_exception</a><br>
|
<a href="throw_exception.html">throw_exception</a><br>
|
||||||
<a href="utility.htm">utility</a><br>
|
<a href="utility.htm">utility</a><br>
|
||||||
<a href="value_init.htm">value_init</a></p>
|
<a href="value_init.htm">value_init</a>
|
||||||
|
</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<hr>
|
<hr>
|
||||||
<p>© Copyright Beman Dawes, 2001</p>
|
<p>© Copyright Beman Dawes, 2001</p>
|
||||||
|
94
utility.htm
94
utility.htm
@@ -151,35 +151,95 @@ void f() {
|
|||||||
<code>result_of<F(T1, T2, ...,
|
<code>result_of<F(T1, T2, ...,
|
||||||
T<em>N</em>)>::type</code> defines the result type
|
T<em>N</em>)>::type</code> defines the result type
|
||||||
of the expression <code>f(t1, t2,
|
of the expression <code>f(t1, t2,
|
||||||
...,t<em>N</em>)</code>. The implementation permits
|
...,t<em>N</em>)</code>. This implementation permits
|
||||||
the type <code>F</code> to be a function pointer,
|
the type <code>F</code> to be a function pointer,
|
||||||
function reference, member function pointer, or class
|
function reference, member function pointer, or class
|
||||||
type. When <code>F</code> is a class type with a
|
type. By default, <em>N</em> may be any value between 0 and
|
||||||
|
10. To change the upper limit, define the macro
|
||||||
|
<code>BOOST_RESULT_OF_NUM_ARGS</code> to the maximum
|
||||||
|
value for <em>N</em>. Class template <code>result_of</code>
|
||||||
|
resides in the header <code><<a
|
||||||
|
href="../../boost/utility/result_of.hpp">boost/utility/result_of.hpp</a>></code>.</p>
|
||||||
|
|
||||||
|
<p>If your compiler supports <code>decltype</code>,
|
||||||
|
then you can enable automatic result type deduction by
|
||||||
|
defining the macro <code>BOOST_RESULT_OF_USE_DECLTYPE</code>,
|
||||||
|
as in the following example.</p>
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<pre>#define BOOST_RESULT_OF_USE_DECLTYPE
|
||||||
|
#include <boost/utility/result_of.hpp>
|
||||||
|
|
||||||
|
struct functor {
|
||||||
|
template<class T>
|
||||||
|
T operator()(T x)
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef boost::result_of<
|
||||||
|
functor(int)
|
||||||
|
>::type type;</pre>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<p>If <code>decltype</code> is not enabled,
|
||||||
|
then automatic result type deduction of function
|
||||||
|
objects is not possible. Instead, <code>result_of</code>
|
||||||
|
uses the following protocol to allow the programmer to
|
||||||
|
specify a type. When <code>F</code> is a class type with a
|
||||||
member type <code>result_type</code>,
|
member type <code>result_type</code>,
|
||||||
<code>result_of<F(T1, T2, ...,
|
<code>result_of<F(T1, T2, ...,
|
||||||
T<em>N</em>)></code> is
|
T<em>N</em>)></code> is
|
||||||
<code>F::result_type</code>. Otherwise,
|
<code>F::result_type</code>. When <code>F</code> does
|
||||||
|
not contain <code>result_type</code>,
|
||||||
<code>result_of<F(T1, T2, ...,
|
<code>result_of<F(T1, T2, ...,
|
||||||
T<em>N</em>)></code> is <code>F::result<F(T1,
|
T<em>N</em>)></code> is <code>F::result<F(T1,
|
||||||
T2, ..., T<em>N</em>)>::type</code> when
|
T2, ..., T<em>N</em>)>::type</code> when
|
||||||
<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>. Note that it is the
|
||||||
information about <code>result_of</code>, see the
|
responsibility of the programmer to ensure that
|
||||||
C++ Library Technical Report, <a
|
function objects accurately advertise their result
|
||||||
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">N1836</a>,
|
type via this protocol, as in the following
|
||||||
or, for motivation and design rationale, the <code>result_of</code> <a
|
example.</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
|
<blockquote>
|
||||||
the header <code><<a
|
<pre>struct functor {
|
||||||
href="../../boost/utility/result_of.hpp">boost/utility/result_of.hpp</a>></code>. By
|
template<class> struct result;
|
||||||
default, <em>N</em> may be any value between 0 and
|
|
||||||
10. To change the upper limit, define the macro
|
template<class F, class T>
|
||||||
<code>BOOST_RESULT_OF_NUM_ARGS</code> to the maximum
|
struct result<F(T)> {
|
||||||
value for <em>N</em>.</p>
|
typedef T type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T operator()(T x)
|
||||||
|
{
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef boost::result_of<
|
||||||
|
functor(int)
|
||||||
|
>::type type;</pre>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
<a name="BOOST_NO_RESULT_OF"></a>
|
<a name="BOOST_NO_RESULT_OF"></a>
|
||||||
<p>This implementation of <code>result_of</code> requires class template partial specialization, the ability to parse function types properly, and support for SFINAE. If <code>result_of</code> is not supported by your compiler, including the header <code>boost/utility/result_of.hpp</code> will define the macro <code>BOOST_NO_RESULT_OF</code>. Contributed by Doug Gregor.</p>
|
<p>This implementation of <code>result_of</code>
|
||||||
|
requires class template partial specialization, the
|
||||||
|
ability to parse function types properly, and support
|
||||||
|
for SFINAE. If <code>result_of</code> is not supported
|
||||||
|
by your compiler, including the header
|
||||||
|
<code>boost/utility/result_of.hpp</code> will
|
||||||
|
define the macro <code>BOOST_NO_RESULT_OF</code>.</p>
|
||||||
|
|
||||||
|
<p>For additional information
|
||||||
|
about <code>result_of</code>, see the C++ Library
|
||||||
|
Technical Report,
|
||||||
|
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">N1836</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>
|
||||||
|
Contributed by Doug Gregor.</p>
|
||||||
|
|
||||||
<h2>Class templates for the Base-from-Member Idiom</h2>
|
<h2>Class templates for the Base-from-Member Idiom</h2>
|
||||||
<p>See <a href="base_from_member.html">separate documentation</a>.</p>
|
<p>See <a href="base_from_member.html">separate documentation</a>.</p>
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "boost/test/minimal.hpp"
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sample POD type
|
// Sample POD type
|
||||||
@@ -215,7 +215,7 @@ template<class T>
|
|||||||
void check_initialized_value ( T const& y )
|
void check_initialized_value ( T const& y )
|
||||||
{
|
{
|
||||||
T initializedValue = boost::initialized_value ;
|
T initializedValue = boost::initialized_value ;
|
||||||
BOOST_CHECK ( y == initializedValue ) ;
|
BOOST_TEST ( y == initializedValue ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
@@ -245,128 +245,125 @@ void check_initialized_value( NonPOD const& )
|
|||||||
template<class T>
|
template<class T>
|
||||||
bool test ( T const& y, T const& z )
|
bool test ( T const& y, T const& z )
|
||||||
{
|
{
|
||||||
const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter();
|
const int errors_before_test = boost::detail::test_errors();
|
||||||
|
|
||||||
check_initialized_value(y);
|
check_initialized_value(y);
|
||||||
|
|
||||||
boost::value_initialized<T> x ;
|
boost::value_initialized<T> x ;
|
||||||
BOOST_CHECK ( y == x ) ;
|
BOOST_TEST ( y == x ) ;
|
||||||
BOOST_CHECK ( y == boost::get(x) ) ;
|
BOOST_TEST ( 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_TEST ( x == z ) ;
|
||||||
|
|
||||||
boost::value_initialized<T> const x_c ;
|
boost::value_initialized<T> const x_c ;
|
||||||
BOOST_CHECK ( y == x_c ) ;
|
BOOST_TEST ( y == x_c ) ;
|
||||||
BOOST_CHECK ( y == boost::get(x_c) ) ;
|
BOOST_TEST ( y == boost::get(x_c) ) ;
|
||||||
T& x_c_ref = const_cast<T&>( boost::get(x_c) ) ;
|
T& x_c_ref = const_cast<T&>( boost::get(x_c) ) ;
|
||||||
x_c_ref = z ;
|
x_c_ref = z ;
|
||||||
BOOST_CHECK ( x_c == z ) ;
|
BOOST_TEST ( x_c == z ) ;
|
||||||
|
|
||||||
boost::value_initialized<T> const copy1 = x;
|
boost::value_initialized<T> const copy1 = x;
|
||||||
BOOST_CHECK ( boost::get(copy1) == boost::get(x) ) ;
|
BOOST_TEST ( boost::get(copy1) == boost::get(x) ) ;
|
||||||
|
|
||||||
boost::value_initialized<T> copy2;
|
boost::value_initialized<T> copy2;
|
||||||
copy2 = x;
|
copy2 = x;
|
||||||
BOOST_CHECK ( boost::get(copy2) == boost::get(x) ) ;
|
BOOST_TEST ( boost::get(copy2) == boost::get(x) ) ;
|
||||||
|
|
||||||
boost::shared_ptr<boost::value_initialized<T> > ptr( new boost::value_initialized<T> );
|
boost::shared_ptr<boost::value_initialized<T> > ptr( new boost::value_initialized<T> );
|
||||||
BOOST_CHECK ( y == *ptr ) ;
|
BOOST_TEST ( 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_TEST ( y == cx ) ;
|
||||||
BOOST_CHECK ( y == boost::get(cx) ) ;
|
BOOST_TEST ( y == boost::get(cx) ) ;
|
||||||
|
|
||||||
boost::value_initialized<T const> const cx_c ;
|
boost::value_initialized<T const> const cx_c ;
|
||||||
BOOST_CHECK ( y == cx_c ) ;
|
BOOST_TEST ( y == cx_c ) ;
|
||||||
BOOST_CHECK ( y == boost::get(cx_c) ) ;
|
BOOST_TEST ( y == boost::get(cx_c) ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return boost::minimal_test::errors_counter() == counter_before_test ;
|
return boost::detail::test_errors() == errors_before_test ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_main(int, char **)
|
int main(int, char **)
|
||||||
{
|
{
|
||||||
BOOST_CHECK ( test( 0,1234 ) ) ;
|
BOOST_TEST ( test( 0,1234 ) ) ;
|
||||||
BOOST_CHECK ( test( 0.0,12.34 ) ) ;
|
BOOST_TEST ( test( 0.0,12.34 ) ) ;
|
||||||
BOOST_CHECK ( test( POD(0,0,0.0), POD('a',1234,56.78f) ) ) ;
|
BOOST_TEST ( test( POD(0,0,0.0), POD('a',1234,56.78f) ) ) ;
|
||||||
BOOST_CHECK ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ;
|
BOOST_TEST ( test( NonPOD( std::string() ), NonPOD( std::string("something") ) ) ) ;
|
||||||
|
|
||||||
NonPOD NonPOD_object( std::string("NonPOD_object") );
|
NonPOD NonPOD_object( std::string("NonPOD_object") );
|
||||||
BOOST_CHECK ( test<NonPOD *>( 0, &NonPOD_object ) ) ;
|
BOOST_TEST ( test<NonPOD *>( 0, &NonPOD_object ) ) ;
|
||||||
|
|
||||||
AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 };
|
AggregatePODStruct zeroInitializedAggregatePODStruct = { 0.0f, '\0', 0 };
|
||||||
AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 };
|
AggregatePODStruct nonZeroInitializedAggregatePODStruct = { 1.25f, 'a', -1 };
|
||||||
BOOST_CHECK ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) );
|
BOOST_TEST ( test(zeroInitializedAggregatePODStruct, nonZeroInitializedAggregatePODStruct) );
|
||||||
|
|
||||||
StringAndInt stringAndInt0;
|
StringAndInt stringAndInt0;
|
||||||
StringAndInt stringAndInt1;
|
StringAndInt stringAndInt1;
|
||||||
stringAndInt0.i = 0;
|
stringAndInt0.i = 0;
|
||||||
stringAndInt1.i = 1;
|
stringAndInt1.i = 1;
|
||||||
stringAndInt1.s = std::string("1");
|
stringAndInt1.s = std::string("1");
|
||||||
BOOST_CHECK ( test(stringAndInt0, stringAndInt1) );
|
BOOST_TEST ( test(stringAndInt0, stringAndInt1) );
|
||||||
|
|
||||||
StructWithDestructor structWithDestructor0;
|
StructWithDestructor structWithDestructor0;
|
||||||
StructWithDestructor structWithDestructor1;
|
StructWithDestructor structWithDestructor1;
|
||||||
structWithDestructor0.i = 0;
|
structWithDestructor0.i = 0;
|
||||||
structWithDestructor1.i = 1;
|
structWithDestructor1.i = 1;
|
||||||
BOOST_CHECK ( test(structWithDestructor0, structWithDestructor1) );
|
BOOST_TEST ( test(structWithDestructor0, structWithDestructor1) );
|
||||||
|
|
||||||
StructWithVirtualFunction structWithVirtualFunction0;
|
StructWithVirtualFunction structWithVirtualFunction0;
|
||||||
StructWithVirtualFunction structWithVirtualFunction1;
|
StructWithVirtualFunction structWithVirtualFunction1;
|
||||||
structWithVirtualFunction0.i = 0;
|
structWithVirtualFunction0.i = 0;
|
||||||
structWithVirtualFunction1.i = 1;
|
structWithVirtualFunction1.i = 1;
|
||||||
BOOST_CHECK ( test(structWithVirtualFunction0, structWithVirtualFunction1) );
|
BOOST_TEST ( test(structWithVirtualFunction0, structWithVirtualFunction1) );
|
||||||
|
|
||||||
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct0;
|
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct0;
|
||||||
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct1;
|
DerivedFromAggregatePODStruct derivedFromAggregatePODStruct1;
|
||||||
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct0) = zeroInitializedAggregatePODStruct;
|
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct0) = zeroInitializedAggregatePODStruct;
|
||||||
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct1) = nonZeroInitializedAggregatePODStruct;
|
static_cast<AggregatePODStruct &>(derivedFromAggregatePODStruct1) = nonZeroInitializedAggregatePODStruct;
|
||||||
BOOST_CHECK ( test(derivedFromAggregatePODStruct0, derivedFromAggregatePODStruct1) );
|
BOOST_TEST ( test(derivedFromAggregatePODStruct0, derivedFromAggregatePODStruct1) );
|
||||||
|
|
||||||
AggregatePODStructWrapper aggregatePODStructWrapper0;
|
AggregatePODStructWrapper aggregatePODStructWrapper0;
|
||||||
AggregatePODStructWrapper aggregatePODStructWrapper1;
|
AggregatePODStructWrapper aggregatePODStructWrapper1;
|
||||||
aggregatePODStructWrapper0.dataMember = zeroInitializedAggregatePODStruct;
|
aggregatePODStructWrapper0.dataMember = zeroInitializedAggregatePODStruct;
|
||||||
aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct;
|
aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct;
|
||||||
BOOST_CHECK ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) );
|
BOOST_TEST ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) );
|
||||||
|
|
||||||
ArrayOfBytes zeroInitializedArrayOfBytes = { 0 };
|
ArrayOfBytes zeroInitializedArrayOfBytes = { 0 };
|
||||||
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes;
|
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes;
|
||||||
BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0);
|
BOOST_TEST (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0);
|
||||||
|
|
||||||
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes2;
|
boost::value_initialized<ArrayOfBytes> valueInitializedArrayOfBytes2;
|
||||||
valueInitializedArrayOfBytes2 = valueInitializedArrayOfBytes;
|
valueInitializedArrayOfBytes2 = valueInitializedArrayOfBytes;
|
||||||
BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), get(valueInitializedArrayOfBytes2), sizeof(ArrayOfBytes)) == 0);
|
BOOST_TEST (std::memcmp(get(valueInitializedArrayOfBytes), get(valueInitializedArrayOfBytes2), sizeof(ArrayOfBytes)) == 0);
|
||||||
|
|
||||||
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester1;
|
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester1;
|
||||||
BOOST_CHECK ( ! get(copyFunctionCallTester1).is_copy_constructed);
|
BOOST_TEST ( ! get(copyFunctionCallTester1).is_copy_constructed);
|
||||||
BOOST_CHECK ( ! get(copyFunctionCallTester1).is_assignment_called);
|
BOOST_TEST ( ! get(copyFunctionCallTester1).is_assignment_called);
|
||||||
|
|
||||||
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester2 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
|
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester2 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
|
||||||
BOOST_CHECK ( get(copyFunctionCallTester2).is_copy_constructed);
|
BOOST_TEST ( get(copyFunctionCallTester2).is_copy_constructed);
|
||||||
BOOST_CHECK ( ! get(copyFunctionCallTester2).is_assignment_called);
|
BOOST_TEST ( ! get(copyFunctionCallTester2).is_assignment_called);
|
||||||
|
|
||||||
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester3;
|
boost::value_initialized<CopyFunctionCallTester> copyFunctionCallTester3;
|
||||||
copyFunctionCallTester3 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
|
copyFunctionCallTester3 = boost::value_initialized<CopyFunctionCallTester>(copyFunctionCallTester1);
|
||||||
BOOST_CHECK ( ! get(copyFunctionCallTester3).is_copy_constructed);
|
BOOST_TEST ( ! get(copyFunctionCallTester3).is_copy_constructed);
|
||||||
BOOST_CHECK ( get(copyFunctionCallTester3).is_assignment_called);
|
BOOST_TEST ( get(copyFunctionCallTester3).is_assignment_called);
|
||||||
|
|
||||||
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester1;
|
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester1;
|
||||||
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester2;
|
boost::value_initialized<SwapFunctionCallTester> swapFunctionCallTester2;
|
||||||
get(swapFunctionCallTester1).data = 1;
|
get(swapFunctionCallTester1).data = 1;
|
||||||
get(swapFunctionCallTester2).data = 2;
|
get(swapFunctionCallTester2).data = 2;
|
||||||
boost::swap(swapFunctionCallTester1, swapFunctionCallTester2);
|
boost::swap(swapFunctionCallTester1, swapFunctionCallTester2);
|
||||||
BOOST_CHECK( get(swapFunctionCallTester1).data == 2 );
|
BOOST_TEST( get(swapFunctionCallTester1).data == 2 );
|
||||||
BOOST_CHECK( get(swapFunctionCallTester2).data == 1 );
|
BOOST_TEST( get(swapFunctionCallTester2).data == 1 );
|
||||||
BOOST_CHECK( get(swapFunctionCallTester1).is_custom_swap_called );
|
BOOST_TEST( get(swapFunctionCallTester1).is_custom_swap_called );
|
||||||
BOOST_CHECK( get(swapFunctionCallTester2).is_custom_swap_called );
|
BOOST_TEST( get(swapFunctionCallTester2).is_custom_swap_called );
|
||||||
|
|
||||||
return 0;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int expected_failures = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user