mirror of
https://github.com/boostorg/unordered.git
synced 2025-10-04 19:51:01 +02:00
Copyright update. Switch back to the version where the sentinel points to itself. Remove alternative versions of swap. Workaround a borland bug or two. More consistent use of class/swap/template. Avoid a few warnings. Add a no-throw swap to the allocator for exception testing. [SVN r3793]
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
|
|
// Copyright 2006-2007 Daniel James.
|
|
// 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)
|
|
|
|
#include <boost/unordered_set.hpp>
|
|
#include <boost/unordered_map.hpp>
|
|
#include <boost/detail/lightweight_test.hpp>
|
|
|
|
struct count_copies
|
|
{
|
|
static int count;
|
|
count_copies() { ++count; }
|
|
count_copies(count_copies const& x) { ++count; }
|
|
private:
|
|
count_copies& operator=(count_copies const&);
|
|
};
|
|
|
|
std::size_t hash_value(count_copies const& x) {
|
|
return 0;
|
|
}
|
|
|
|
bool operator==(count_copies const& x, count_copies const& y) {
|
|
return true;
|
|
}
|
|
|
|
int count_copies::count;
|
|
|
|
template <class T>
|
|
void unnecessary_copy_test(T*)
|
|
{
|
|
count_copies::count = 0;
|
|
T x;
|
|
typename T::value_type a;
|
|
BOOST_TEST(count_copies::count == 1);
|
|
x.insert(a);
|
|
BOOST_TEST(count_copies::count == 2);
|
|
}
|
|
|
|
|
|
int main()
|
|
{
|
|
unnecessary_copy_test((boost::unordered_set<count_copies>*) 0);
|
|
unnecessary_copy_test((boost::unordered_multiset<count_copies>*) 0);
|
|
unnecessary_copy_test((boost::unordered_map<int, count_copies>*) 0);
|
|
unnecessary_copy_test((boost::unordered_multimap<int, count_copies>*) 0);
|
|
|
|
return boost::report_errors();
|
|
}
|