]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/example/features/check.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
7 #include <boost/contract.hpp>
9 int gcd(int const a
, int const b
) {
11 boost::contract::check c
= boost::contract::function()
13 BOOST_CONTRACT_ASSERT(a
> 0);
14 BOOST_CONTRACT_ASSERT(b
> 0);
17 BOOST_CONTRACT_ASSERT(result
<= a
);
18 BOOST_CONTRACT_ASSERT(result
<= b
);
32 // Implementation checks (via nullary functor).
33 boost::contract::check c
= [&] {
34 BOOST_CONTRACT_ASSERT(gcd(12, 28) == 4);
35 BOOST_CONTRACT_ASSERT(gcd(4, 14) == 2);