utility/swap/test/swap_test_class.hpp
Joseph Gauterin 6098304ea8 Corrected duplicated file contents
[SVN r47607]
2008-07-19 19:40:12 +00:00

85 lines
1.5 KiB
C++

// Copyright (c) 2007-2008 Joseph Gauterin
//
// 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)
// Tests class used by the Boost.Swap tests
#ifndef BOOST_UTILITY_SWAP_TEST_CLASS_HPP
#define BOOST_UTILITY_SWAP_TEST_CLASS_HPP
class swap_test_class
{
public:
swap_test_class()
{
++constructCount();
}
~swap_test_class()
{
++destructCount();
}
swap_test_class(const swap_test_class&)
{
++copyCount();
++destructCount();
}
swap_test_class& operator=(const swap_test_class&)
{
++copyCount();
return *this;
}
void swap(swap_test_class& other)
{
++swapCount();
}
static unsigned int swap_count(){ return swapCount(); }
static unsigned int copy_count(){ return copyCount(); }
static unsigned int construct_count(){ return constructCount(); }
static unsigned int destruct_count(){ return destructCount(); }
static void reset()
{
swapCount() = 0;
copyCount() = 0;
constructCount() = 0;
destructCount() = 0;
}
private:
static unsigned int& swapCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& copyCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& constructCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& destructCount()
{
static unsigned int value = 0;
return value;
}
};
#endif