function.hpp:

- Added self-assignment check in operator= and set()

function_template.hpp:
	- Added self-assignment check in operator= and set()


[SVN r10431]
This commit is contained in:
Douglas Gregor
2001-06-26 13:38:58 +00:00
parent 0270911a43
commit 07c66d01fa
2 changed files with 18 additions and 0 deletions

View File

@ -462,6 +462,9 @@ namespace boost {
function& operator=(const function& f) function& operator=(const function& f)
{ {
if (this == &f)
return *this;
const base_type& bf = static_cast<const base_type&>(f); const base_type& bf = static_cast<const base_type&>(f);
base_type* self = this; base_type* self = this;
self->set(bf); self->set(bf);
@ -470,6 +473,9 @@ namespace boost {
void set(const function& f) void set(const function& f)
{ {
if (this == &f)
return;
const base_type& bf = static_cast<const base_type&>(f); const base_type& bf = static_cast<const base_type&>(f);
base_type* self = this; base_type* self = this;
self->set(bf); self->set(bf);

View File

@ -1044,6 +1044,9 @@ namespace boost {
// Assignment from another BOOST_FUNCTION_FUNCTION // Assignment from another BOOST_FUNCTION_FUNCTION
BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f) BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f)
{ {
if (this == &f)
return *this;
clear(); clear();
if (!f.empty()) { if (!f.empty()) {
@ -1064,6 +1067,9 @@ namespace boost {
// Assignment from another BOOST_FUNCTION_FUNCTION // Assignment from another BOOST_FUNCTION_FUNCTION
void set(const BOOST_FUNCTION_FUNCTION& f) void set(const BOOST_FUNCTION_FUNCTION& f)
{ {
if (this == &f)
return;
clear(); clear();
if (!f.empty()) { if (!f.empty()) {
@ -1624,6 +1630,9 @@ namespace boost {
// Assignment from another BOOST_FUNCTION_FUNCTION // Assignment from another BOOST_FUNCTION_FUNCTION
BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f) BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f)
{ {
if (this == &f)
return *this;
clear(); clear();
if (!f.empty()) { if (!f.empty()) {
@ -1644,6 +1653,9 @@ namespace boost {
// Assignment from another BOOST_FUNCTION_FUNCTION // Assignment from another BOOST_FUNCTION_FUNCTION
void set(const BOOST_FUNCTION_FUNCTION& f) void set(const BOOST_FUNCTION_FUNCTION& f)
{ {
if (this == &f)
return;
clear(); clear();
if (!f.empty()) { if (!f.empty()) {