]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/example/n1962/equal.cpp
2 // Copyright (C) 2008-2018 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0 (see accompanying
4 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
5 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
8 #include <boost/contract.hpp>
11 // Forward declaration because == and != contracts use one another's function.
13 bool operator==(T
const& left
, T
const& right
);
16 bool operator!=(T
const& left
, T
const& right
) {
18 boost::contract::check c
= boost::contract::function()
20 BOOST_CONTRACT_ASSERT(result
== !(left
== right
));
24 return result
= (left
.value
!= right
.value
);
28 bool operator==(T
const& left
, T
const& right
) {
30 boost::contract::check c
= boost::contract::function()
32 BOOST_CONTRACT_ASSERT(result
== !(left
!= right
));
36 return result
= (left
.value
== right
.value
);
39 struct number
{ int value
; };
45 assert((n
== n
) == true); // Explicitly call operator==.
46 assert((n
!= n
) == false); // Explicitly call operator!=.