]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/unordered/doc/src_code/point2.cpp
2 // Copyright 2006-2009 Daniel James.
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/unordered_set.hpp>
7 #include <boost/functional/hash.hpp>
8 #include <boost/detail/lightweight_test.hpp>
16 bool operator==(point
const& p1
, point
const& p2
)
18 return p1
.x
== p2
.x
&& p1
.y
== p2
.y
;
21 std::size_t hash_value(point
const& p
) {
23 boost::hash_combine(seed
, p
.x
);
24 boost::hash_combine(seed
, p
.y
);
28 // Now the default function objects work.
29 boost::unordered_multiset
<point
> points
;
33 point x
[] = {{1,2}, {3,4}, {1,5}, {1,2}};
34 for(int i
= 0; i
< sizeof(x
) / sizeof(point
); ++i
)
36 BOOST_TEST(points
.count(x
[0]) == 2);
37 BOOST_TEST(points
.count(x
[1]) == 1);
39 BOOST_TEST(points
.count(y
) == 0);
41 return boost::report_errors();