started advanced topics section in the docs

This commit is contained in:
Lorenzo Caminiti
2015-06-27 08:03:34 -07:00
parent be3a974847
commit 2fb2ddc367
125 changed files with 2979 additions and 3114 deletions

23
example/n1962/sum.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include <boost/contract.hpp>
#include <boost/detail/lightweight_test.hpp>
int sum(int count, int* array) {
int result;
auto c = boost::contract::function()
.precondition([&] {
BOOST_CONTRACT_ASSERT(count % 4 == 0);
})
;
result = 0;
for(int i = 0; i < count; ++i) result += array[i];
return result;
}
int main() {
int a[4] = {1, 2, 3, 4};
BOOST_TEST_EQ(sum(4, a), 10);
return boost::report_errors();
}