2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-22 17:32:55 +00:00

Add std::swap overload for int_wrapper. This prevents a crash in

container_proxy::swap_elements in test_deque_proxy.py with -O2 or higher
on gcc 2.96 for i386-redhat-linux


[SVN r20458]
This commit is contained in:
Raoul Gough
2003-10-22 23:28:37 +00:00
parent 87217f8009
commit cb26cf1a5b

View File

@@ -21,6 +21,7 @@
#include <string>
#include <sstream>
#include <algorithm>
#include <stdio.h>
struct int_wrapper {
@@ -61,7 +62,7 @@ int_wrapper::int_wrapper ()
{
if (our_trace_flag)
{
printf ("int_wrapper %u ()\n", m_obj_number);
printf ("int_wrapper %u () at %p\n", m_obj_number, this);
}
}
@@ -71,9 +72,10 @@ int_wrapper::int_wrapper (int i)
{
if (our_trace_flag)
{
printf ("int_wrapper %u (%d)\n"
printf ("int_wrapper %u (%d) at %p\n"
, m_obj_number
, m_int);
, m_int
, this);
}
}
@@ -83,9 +85,11 @@ int_wrapper::int_wrapper (int_wrapper const &other)
{
if (our_trace_flag)
{
printf ("int_wrapper %u (int_wrapper %u)\n"
printf ("int_wrapper %u (int_wrapper %u at %p) at %p\n"
, m_obj_number
, other.m_obj_number);
, other.m_obj_number
, &other
, this);
}
}
@@ -93,9 +97,11 @@ int_wrapper &int_wrapper::operator= (int_wrapper const &other)
{
if (our_trace_flag)
{
printf ("int_wrapper %u = int_wrapper %u\n"
printf ("int_wrapper %u at %p = int_wrapper %u at %p\n"
, m_obj_number
, other.m_obj_number);
, this
, other.m_obj_number
, &other);
}
m_int = other.m_int;
@@ -107,7 +113,7 @@ int_wrapper::~int_wrapper ()
{
if (our_trace_flag)
{
printf ("~int_wrapper %u\n", m_obj_number);
printf ("~int_wrapper %u at %p\n", m_obj_number, this);
}
m_int = 0xbaaaaaad;
@@ -168,4 +174,19 @@ int compare (int_wrapper const &lhs, int_wrapper const &rhs)
}
}
namespace std {
void swap (int_wrapper &first, int_wrapper &second) {
if (int_wrapper::our_trace_flag)
{
printf ("std::swap (int_wrapper %u at %p, int_wrapper %u at %p)\n"
, first.m_obj_number
, &first
, second.m_obj_number
, &second);
}
swap (first.m_int, second.m_int); // Don't swap object numbers
}
}
#endif // int_wrapper_rmg_20030910_included