]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/contract/example/features/lambda.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>
20 std::for_each(v
.cbegin(), v
.cend(),
21 // Contract for a lambda function.
22 [&total
] (int const x
) {
23 boost::contract::old_ptr
<int> old_total
=
24 BOOST_CONTRACT_OLDOF(total
);
25 boost::contract::check c
= boost::contract::function()
27 BOOST_CONTRACT_ASSERT(
28 total
< std::numeric_limits
<int>::max() - x
);
31 BOOST_CONTRACT_ASSERT(total
== *old_total
+ x
);
35 total
+= x
; // Lambda function body.