mirror of
https://github.com/boostorg/utility.git
synced 2025-10-06 14:00:55 +02:00
Compare commits
8 Commits
boost-1.45
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
|
6032348b4c | ||
|
3279399fe3 | ||
|
87875cadda | ||
|
c58748cfd9 | ||
|
58bb88d4bd | ||
|
11d50ecb9f | ||
|
636283d7c2 | ||
|
1df0bf80bc |
72
assert.html
72
assert.html
@@ -17,36 +17,89 @@
|
|||||||
<td colspan="2" height="64"> </td>
|
<td colspan="2" height="64"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<p>
|
||||||
|
<a href="#BOOST_ASSERT">BOOST_ASSERT</a><br>
|
||||||
|
<a href="#BOOST_ASSERT_MSG">BOOST_ASSERT_MSG</a><br>
|
||||||
|
<a href="#BOOST_VERIFY">BOOST_VERIFY</a></p>
|
||||||
|
|
||||||
|
<h2><a name="BOOST_ASSERT">BOOST_ASSERT</a></h2>
|
||||||
<p>
|
<p>
|
||||||
The header <STRONG><boost/assert.hpp></STRONG> defines the macro <b>BOOST_ASSERT</b>,
|
The header <STRONG><boost/assert.hpp></STRONG> defines the macro <b>BOOST_ASSERT</b>,
|
||||||
which is similar to the standard <STRONG>assert</STRONG> macro defined in <STRONG><cassert></STRONG>.
|
which is similar to the standard <STRONG>assert</STRONG> macro defined in <STRONG><cassert></STRONG>.
|
||||||
The macro is intended to be used in Boost libraries.
|
The macro is intended to be used in both Boost libraries and user
|
||||||
|
code.
|
||||||
</p>
|
</p>
|
||||||
<P>By default, <tt>BOOST_ASSERT(expr)</tt> is equivalent to <tt>assert(expr)</tt>.</P>
|
<P>By default, <tt>BOOST_ASSERT(expr)</tt> is equivalent to <tt>assert(expr)</tt>.</P>
|
||||||
<P>When the macro <STRONG>BOOST_DISABLE_ASSERTS</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
<P>If the macro <STRONG>BOOST_DISABLE_ASSERTS</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||||
is included, <tt>BOOST_ASSERT(expr)</tt> is defined as <tt>((void)0)</tt>. This
|
is included, <tt>BOOST_ASSERT(expr)</tt> is defined as <tt>((void)0)</tt>. This
|
||||||
allows users to selectively disable <STRONG>BOOST_ASSERT</STRONG> without
|
allows users to selectively disable <STRONG>BOOST_ASSERT</STRONG> without
|
||||||
affecting the definition of the standard <STRONG>assert</STRONG>.</P>
|
affecting the definition of the standard <STRONG>assert</STRONG>.</P>
|
||||||
<P>When the macro <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
<P>If the macro <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||||
is included, <tt>BOOST_ASSERT(expr)</tt> evaluates <b>expr</b> and, if the
|
is included, <tt>BOOST_ASSERT(expr)</tt> evaluates <b>expr</b> and, if the
|
||||||
result is false, evaluates the expression</P>
|
result is false, evaluates the expression</P>
|
||||||
|
<blockquote>
|
||||||
<P><tt>::boost::assertion_failed(#expr, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>,
|
<P><tt>::boost::assertion_failed(#expr, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>,
|
||||||
__FILE__, __LINE__)</tt></P>
|
__FILE__, __LINE__)</tt></P>
|
||||||
|
</blockquote>
|
||||||
<P><STRONG>assertion_failed</STRONG> is declared in <STRONG><boost/assert.hpp></STRONG>
|
<P><STRONG>assertion_failed</STRONG> is declared in <STRONG><boost/assert.hpp></STRONG>
|
||||||
as</P>
|
as</P>
|
||||||
<pre>
|
<blockquote>
|
||||||
namespace boost
|
<pre>namespace boost
|
||||||
{
|
{
|
||||||
|
void assertion_failed(char const * expr, char const * function, char const * file, long line);
|
||||||
void assertion_failed(char const * expr, char const * function, char const * file, long line);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
</blockquote>
|
||||||
<p>but it is never defined. The user is expected to supply an appropriate
|
<p>but it is never defined. The user is expected to supply an appropriate
|
||||||
definition.</p>
|
definition.</p>
|
||||||
<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>
|
||||||
|
|
||||||
|
<h2><a name="BOOST_ASSERT_MSG">BOOST_ASSERT_MSG</a></h2>
|
||||||
|
<p>
|
||||||
|
The header <STRONG><boost/assert.hpp></STRONG> defines the macro <b>BOOST_ASSERT_MSG</b>,
|
||||||
|
which is similar to the standard <STRONG>assert</STRONG> macro defined in <STRONG><cassert></STRONG>,
|
||||||
|
but with an additional macro parameter supplying an error message. The macro is intended to be used in both Boost libraries
|
||||||
|
and user code.
|
||||||
|
</p>
|
||||||
|
<P> <tt>BOOST_ASSERT_MSG(expr, msg)</tt> is equivalent to <code>
|
||||||
|
((void)0)</code> if <b>BOOST_DISABLE_ASSERTS</b> or <b>NDEBUG</b> are
|
||||||
|
defined or <code>expr</code> evaluates to <code>true</code>. If those
|
||||||
|
macros and <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> are not
|
||||||
|
defined, and <code>expr</code> evaluates to <code>false</code>, an error
|
||||||
|
message that includes <tt>#expr</tt>, <tt>msg</tt>, <tt> <a href="current_function.html">BOOST_CURRENT_FUNCTION</a></tt>, <tt>
|
||||||
|
__FILE__</tt>, and <tt>__LINE__</tt> is sent to output stream <b>
|
||||||
|
BOOST_ASSERT_MSG_OSTREAM</b>
|
||||||
|
and <code>std::abort()</code> is called.</P>
|
||||||
|
<P> <b>BOOST_ASSERT_MSG_OSTREAM</b> defines the output stream. It defaults to <code>std::cerr</code>.
|
||||||
|
Integrated development environments (IDE's) like Microsoft Visual Studio
|
||||||
|
may produce easier to understand output if messages go to a different
|
||||||
|
stream, such as <code>std::cout</code>. Users may define <b>BOOST_ASSERT_MSG_OSTREAM</b> before including <STRONG><boost/assert.hpp></STRONG>
|
||||||
|
to specify a different output stream. </P>
|
||||||
|
<P>If the macro <STRONG>BOOST_ENABLE_ASSERT_HANDLER</STRONG> is defined when <STRONG><boost/assert.hpp></STRONG>
|
||||||
|
is included, instead of sending a error message to an output
|
||||||
|
stream, this expression is evaluated</P>
|
||||||
|
<blockquote>
|
||||||
|
<P><tt>::boost::assertion_failed_msg(#expr, msg, <a href="current_function.html">BOOST_CURRENT_FUNCTION</a>,
|
||||||
|
__FILE__, __LINE__)</tt></P>
|
||||||
|
</blockquote>
|
||||||
|
<P><STRONG>assertion_failed_msg</STRONG> is declared in <STRONG><boost/assert.hpp></STRONG>
|
||||||
|
as</P>
|
||||||
|
<blockquote>
|
||||||
|
<pre>namespace boost
|
||||||
|
{
|
||||||
|
void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line);
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</blockquote>
|
||||||
|
<p>but it is never defined. The user is expected to supply an appropriate
|
||||||
|
definition.</p>
|
||||||
|
<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_MSG</STRONG>
|
||||||
|
will be redefined each time as specified above.</P>
|
||||||
|
|
||||||
|
<h2><a name="BOOST_VERIFY">BOOST_VERIFY</a></h2>
|
||||||
<p><STRONG><boost/assert.hpp></STRONG> also defines the macro <STRONG>BOOST_VERIFY</STRONG>.
|
<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
|
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
|
the expression that is passed to <STRONG>BOOST_VERIFY</STRONG> is always
|
||||||
@@ -54,7 +107,8 @@ void assertion_failed(char const * expr, char const * function, char const * fil
|
|||||||
effects; it can also help suppress warnings about unused variables when the
|
effects; it can also help suppress warnings about unused variables when the
|
||||||
only use of the variable is inside an assertion.</p>
|
only use of the variable is inside an assertion.</p>
|
||||||
<p><br>
|
<p><br>
|
||||||
<small>Copyright <20> 2002, 2007 by Peter Dimov. Distributed under the Boost Software
|
<small>Copyright <20> 2002, 2007 by Peter Dimov. Copyright <20> 2011
|
||||||
|
by Beman Dawes. Distributed under the Boost Software
|
||||||
License, Version 1.0. See accompanying file <A href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
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>.</small></p>
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>.</small></p>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
// assert_test.cpp - a test for boost/assert.hpp
|
// assert_test.cpp - a test for boost/assert.hpp
|
||||||
//
|
//
|
||||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||||
|
// Copyright (2) Beman Dawes 2011
|
||||||
//
|
//
|
||||||
// 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
|
||||||
@@ -20,6 +21,11 @@ void test_default()
|
|||||||
BOOST_ASSERT(x);
|
BOOST_ASSERT(x);
|
||||||
BOOST_ASSERT(x == 1);
|
BOOST_ASSERT(x == 1);
|
||||||
BOOST_ASSERT(&x);
|
BOOST_ASSERT(&x);
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(1, "msg");
|
||||||
|
BOOST_ASSERT_MSG(x, "msg");
|
||||||
|
BOOST_ASSERT_MSG(x == 1, "msg");
|
||||||
|
BOOST_ASSERT_MSG(&x, "msg");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BOOST_DISABLE_ASSERTS
|
#define BOOST_DISABLE_ASSERTS
|
||||||
@@ -34,13 +40,23 @@ void test_disabled()
|
|||||||
BOOST_ASSERT(x == 1);
|
BOOST_ASSERT(x == 1);
|
||||||
BOOST_ASSERT(&x);
|
BOOST_ASSERT(&x);
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(1, "msg");
|
||||||
|
BOOST_ASSERT_MSG(x, "msg");
|
||||||
|
BOOST_ASSERT_MSG(x == 1, "msg");
|
||||||
|
BOOST_ASSERT_MSG(&x, "msg");
|
||||||
|
|
||||||
BOOST_ASSERT(0);
|
BOOST_ASSERT(0);
|
||||||
BOOST_ASSERT(!x);
|
BOOST_ASSERT(!x);
|
||||||
BOOST_ASSERT(x == 0);
|
BOOST_ASSERT(x == 0);
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(0, "msg");
|
||||||
|
BOOST_ASSERT_MSG(!x, "msg");
|
||||||
|
BOOST_ASSERT_MSG(x == 0, "msg");
|
||||||
|
|
||||||
void * p = 0;
|
void * p = 0;
|
||||||
|
|
||||||
BOOST_ASSERT(p);
|
BOOST_ASSERT(p);
|
||||||
|
BOOST_ASSERT_MSG(p, "msg");
|
||||||
|
|
||||||
// supress warnings
|
// supress warnings
|
||||||
p = &x;
|
p = &x;
|
||||||
@@ -55,6 +71,7 @@ void test_disabled()
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
int handler_invoked = 0;
|
int handler_invoked = 0;
|
||||||
|
int msg_handler_invoked = 0;
|
||||||
|
|
||||||
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
|
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
|
||||||
{
|
{
|
||||||
@@ -66,11 +83,24 @@ void boost::assertion_failed(char const * expr, char const * function, char cons
|
|||||||
++handler_invoked;
|
++handler_invoked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void boost::assertion_failed_msg(char const * expr, char const * msg, char const * function,
|
||||||
|
char const * file, long line)
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_STDC_NAMESPACE)
|
||||||
|
using std::printf;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("Expression: %s Message: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n",
|
||||||
|
expr, msg, function, file, line);
|
||||||
|
++msg_handler_invoked;
|
||||||
|
}
|
||||||
|
|
||||||
struct X
|
struct X
|
||||||
{
|
{
|
||||||
static void f()
|
static void f()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(0);
|
BOOST_ASSERT(0);
|
||||||
|
BOOST_ASSERT_MSG(0, "msg f()");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -83,21 +113,35 @@ void test_handler()
|
|||||||
BOOST_ASSERT(x == 1);
|
BOOST_ASSERT(x == 1);
|
||||||
BOOST_ASSERT(&x);
|
BOOST_ASSERT(&x);
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(1, "msg2");
|
||||||
|
BOOST_ASSERT_MSG(x, "msg3");
|
||||||
|
BOOST_ASSERT_MSG(x == 1, "msg4");
|
||||||
|
BOOST_ASSERT_MSG(&x, "msg5");
|
||||||
|
|
||||||
BOOST_ASSERT(0);
|
BOOST_ASSERT(0);
|
||||||
BOOST_ASSERT(!x);
|
BOOST_ASSERT(!x);
|
||||||
BOOST_ASSERT(x == 0);
|
BOOST_ASSERT(x == 0);
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(0,"msg 0");
|
||||||
|
BOOST_ASSERT_MSG(!x, "msg !x");
|
||||||
|
BOOST_ASSERT_MSG(x == 0, "msg x == 0");
|
||||||
|
|
||||||
void * p = 0;
|
void * p = 0;
|
||||||
|
|
||||||
BOOST_ASSERT(p);
|
BOOST_ASSERT(p);
|
||||||
|
BOOST_ASSERT_MSG(p, "msg p");
|
||||||
|
|
||||||
X::f();
|
X::f();
|
||||||
|
|
||||||
BOOST_ASSERT(handler_invoked == 5);
|
BOOST_ASSERT(handler_invoked == 5);
|
||||||
BOOST_TEST(handler_invoked == 5);
|
BOOST_TEST(handler_invoked == 5);
|
||||||
|
|
||||||
|
BOOST_ASSERT_MSG(msg_handler_invoked == 5, "msg_handler_invoked count is wrong");
|
||||||
|
BOOST_TEST(msg_handler_invoked == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef BOOST_ENABLE_ASSERT_HANDLER
|
#undef BOOST_ENABLE_ASSERT_HANDLER
|
||||||
|
#undef BOOST_ENABLE_ASSERT_MSG_HANDLER
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
//
|
//
|
||||||
// boost/assert.hpp - BOOST_ASSERT(expr)
|
// boost/assert.hpp - BOOST_ASSERT(expr)
|
||||||
|
// BOOST_ASSERT_MSG(expr, msg)
|
||||||
|
// BOOST_VERIFY(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
|
// Copyright (c) 2007 Peter Dimov
|
||||||
|
// Copyright (c) Beman Dawes 2011
|
||||||
//
|
//
|
||||||
// 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
|
||||||
@@ -13,6 +16,16 @@
|
|||||||
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------//
|
||||||
|
// BOOST_ASSERT //
|
||||||
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
#undef BOOST_ASSERT
|
#undef BOOST_ASSERT
|
||||||
|
|
||||||
#if defined(BOOST_DISABLE_ASSERTS)
|
#if defined(BOOST_DISABLE_ASSERTS)
|
||||||
@@ -25,18 +38,86 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
void assertion_failed(char const * expr,
|
||||||
void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
|
char const * function, char const * file, long line); // user defined
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
#define BOOST_ASSERT(expr) ((expr) \
|
||||||
|
? ((void)0) \
|
||||||
|
: ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# 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
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------//
|
||||||
|
// BOOST_ASSERT_MSG //
|
||||||
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
# undef BOOST_ASSERT_MSG
|
||||||
|
|
||||||
|
#if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
|
||||||
|
|
||||||
|
#define BOOST_ASSERT_MSG(expr, msg) ((void)0)
|
||||||
|
|
||||||
|
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
|
||||||
|
|
||||||
|
#include <boost/current_function.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
void assertion_failed_msg(char const * expr, char const * msg,
|
||||||
|
char const * function, char const * file, long line); // user defined
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#define BOOST_ASSERT_MSG(expr, msg) ((expr) \
|
||||||
|
? ((void)0) \
|
||||||
|
: ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifndef BOOST_ASSERT_HPP
|
||||||
|
#define BOOST_ASSERT_HPP
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <boost/current_function.hpp>
|
||||||
|
|
||||||
|
// IDE's like Visual Studio perform better if output goes to std::cout or
|
||||||
|
// some other stream, so allow user to configure output stream:
|
||||||
|
#ifndef BOOST_ASSERT_MSG_OSTREAM
|
||||||
|
# define BOOST_ASSERT_MSG_OSTREAM std::cerr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace assertion
|
||||||
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
inline void assertion_failed_msg(char const * expr, char const * msg, char const * function,
|
||||||
|
char const * file, long line)
|
||||||
|
{
|
||||||
|
BOOST_ASSERT_MSG_OSTREAM
|
||||||
|
<< "***** Internal Program Error - assertion (" << expr << ") failed in "
|
||||||
|
<< function << ":\n"
|
||||||
|
<< file << '(' << line << "): " << msg << std::endl;
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
} // detail
|
||||||
|
} // assertion
|
||||||
|
} // detail
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BOOST_ASSERT_MSG(expr, msg) ((expr) \
|
||||||
|
? ((void)0) \
|
||||||
|
: ::boost::assertion::detail::assertion_failed_msg(#expr, msg, \
|
||||||
|
BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------//
|
||||||
|
// BOOST_VERIFY //
|
||||||
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
#undef BOOST_VERIFY
|
#undef BOOST_VERIFY
|
||||||
|
|
||||||
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
|
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
|
||||||
|
@@ -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
|
||||||
|
|
||||||
|
@@ -35,10 +35,7 @@ struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
|
|||||||
|
|
||||||
#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE)
|
#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE)
|
||||||
|
|
||||||
// As of N2588, C++0x result_of only supports function call
|
// Uses declval following N3225 20.7.7.6 when F is not a pointer.
|
||||||
// expressions of the form f(x). This precludes support for member
|
|
||||||
// function pointers, which are invoked with expressions of the form
|
|
||||||
// o->*f(x). This implementation supports both.
|
|
||||||
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_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
||||||
@@ -56,18 +53,15 @@ struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
# define BOOST_RESULT_OF_STATIC_MEMBERS(z, n, _) \
|
|
||||||
static T ## n t ## n; \
|
|
||||||
/**/
|
|
||||||
|
|
||||||
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)>
|
||||||
class cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
||||||
{
|
{
|
||||||
static F f;
|
typedef decltype(
|
||||||
BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _)
|
boost::declval<F>()(
|
||||||
public:
|
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), declval<T, >() BOOST_PP_INTERCEPT)
|
||||||
typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type;
|
)
|
||||||
|
) type;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@@ -13,7 +13,9 @@
|
|||||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||||
#include <boost/preprocessor/punctuation/comma_if.hpp>
|
#include <boost/preprocessor/punctuation/comma_if.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_shifted_params.hpp>
|
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||||
|
#include <boost/preprocessor/facilities/intercept.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/if.hpp>
|
||||||
@@ -22,6 +24,7 @@
|
|||||||
#include <boost/type_traits/is_pointer.hpp>
|
#include <boost/type_traits/is_pointer.hpp>
|
||||||
#include <boost/type_traits/is_member_function_pointer.hpp>
|
#include <boost/type_traits/is_member_function_pointer.hpp>
|
||||||
#include <boost/type_traits/remove_cv.hpp>
|
#include <boost/type_traits/remove_cv.hpp>
|
||||||
|
#include <boost/utility/declval.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
|
||||||
|
10
index.html
10
index.html
@@ -14,21 +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="doc/html/declval.html">declval</a><br>
|
<a href="doc/html/declval.html">declval</a><br>
|
||||||
<a href="enable_if.html">enable_if</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>
|
||||||
@@ -41,4 +48,3 @@
|
|||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->07 November, 2006<!--webbot bot="Timestamp" endspan i-checksum="39368" --></p>
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->07 November, 2006<!--webbot bot="Timestamp" endspan i-checksum="39368" --></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@@ -98,6 +98,11 @@ struct no_result_type_or_result_of
|
|||||||
unsigned int operator()();
|
unsigned int operator()();
|
||||||
unsigned short operator()() volatile;
|
unsigned short operator()() volatile;
|
||||||
const unsigned short operator()() const volatile;
|
const unsigned short operator()() const volatile;
|
||||||
|
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
short operator()(int&&);
|
||||||
|
int operator()(int&);
|
||||||
|
long operator()(int const&);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -108,6 +113,11 @@ struct no_result_type_or_result_of_template
|
|||||||
unsigned int operator()();
|
unsigned int operator()();
|
||||||
unsigned short operator()() volatile;
|
unsigned short operator()() volatile;
|
||||||
const unsigned short operator()() const volatile;
|
const unsigned short operator()() const volatile;
|
||||||
|
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
short operator()(int&&);
|
||||||
|
int operator()(int&);
|
||||||
|
long operator()(int const&);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct X {};
|
struct X {};
|
||||||
@@ -232,6 +242,14 @@ int main()
|
|||||||
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of_template<void>(double)>::type, short>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of_template<void>(double)>::type, short>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of_template<void>(void)>::type, unsigned short>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of_template<void>(void)>::type, unsigned short>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of_template<void>(void)>::type, const unsigned short>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of_template<void>(void)>::type, const unsigned short>::value));
|
||||||
|
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(int&&)>::type, short>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(int&)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(int const&)>::type, long>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(int&&)>::type, short>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(int&)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(int const&)>::type, long>::value));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -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