Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73745 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2011-08-14 13:09:09


Author: trademark
Date: 2011-08-14 13:09:08 EDT (Sun, 14 Aug 2011)
New Revision: 73745
URL: http://svn.boost.org/trac/boost/changeset/73745

Log:
The struct no_null_size_contract and strict_size_contract are designed to manage the size expected and the reaction from a violation of this contract.
Added:
   sandbox/SOC/2011/checks/boost/checks/limits.hpp (contents, props changed)

Added: sandbox/SOC/2011/checks/boost/checks/limits.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2011/checks/boost/checks/limits.hpp 2011-08-14 13:09:08 EDT (Sun, 14 Aug 2011)
@@ -0,0 +1,39 @@
+// Boost checks/limits.hpp header file ------------------------------------//
+// (C) Copyright Pierre Talbot 2011
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#ifndef BOOST_CHECK_LIMITS_HPP
+#define BOOST_CHECK_LIMITS_HPP
+
+#include <boost/static_assert.hpp>
+
+namespace boost{
+ namespace checks{
+
+template <size_t expected_size, class exception_size_failure = std::invalid_argument>
+struct strict_size_contract
+{
+ static void respect_size_contract(size_t valid_values_counted)
+ {
+ BOOST_STATIC_ASSERT_MSG( expected_size > 0 , "The expected size must be greater than 0" );
+ if( valid_values_counted != expected_size )
+ throw exception_size_failure("Too few or too much valid values in the sequence.") ;
+ }
+};
+
+template <class exception_size_failure = std::invalid_argument>
+struct no_null_size_contract
+{
+ static void respect_size_contract(size_t valid_values_counted)
+ {
+ if( valid_values_counted == 0 )
+ throw exception_size_failure("No valid value in this sequence.") ;
+ }
+};
+
+}}
+
+#endif // BOOST_CHECKS_LIMITS_HPP
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk