added const volatile invariants

This commit is contained in:
Lorenzo Caminiti
2015-11-11 07:47:36 -08:00
parent 72eb227bcf
commit 8e9d7474f1
63 changed files with 1362 additions and 192 deletions

View File

@@ -1,7 +1,6 @@
//[stroustrup97_string
#include <boost/contract.hpp>
#include <boost/bind.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <cstring>
#include <iostream>
@@ -37,13 +36,11 @@ public:
if(chars_[size_] != '\0') throw invariant_error();
}
static void string_precondition(char const* const chars) {
if(!chars) throw string::null_error();
if(strlen(chars) > too_large) throw too_large_error();
}
/* implicit */ string(char const* chars) :
boost::contract::constructor_precondition<string>(
boost::bind(&string_precondition, chars))
boost::contract::constructor_precondition<string>([&] {
if(!chars) throw string::null_error();
if(strlen(chars) > too_large) throw too_large_error();
})
{
auto c = boost::contract::constructor(this); // Check invariants.
init(chars);