|
|
@@ -62,19 +62,23 @@ namespace contract {
|
|
|
expr pop_exception( __VA_ARGS__ ), \
|
|
|
get_default_message( "precondition failed: ", expr ) )
|
|
|
|
|
|
-//#define ensures( cond, ... ) \
|
|
|
+/*
|
|
|
+#define ensures( cond, ... ) \
|
|
|
contract::_contract_impl< exception_type( std::runtime_error, ##__VA_ARGS__ )>( \
|
|
|
cond , ##__VA_ARGS__ , \
|
|
|
get_default_message( "postcondition failed: ", cond ) )
|
|
|
-
|
|
|
-// RVO works if expr is an rvalue, but not if it is an
|
|
|
-// lvalue. e.g:
|
|
|
-// return ensures( expression, condition );
|
|
|
-// will rvo the object (if expression is rvo-able)
|
|
|
-// but
|
|
|
-// return ensures( var, condition );
|
|
|
-// will not, instead copies
|
|
|
-// By making _ an argument, both options will move
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * RVO works if expr is an rvalue, but not if it is an
|
|
|
+ * lvalue. e.g:
|
|
|
+ * return ensures( expression, condition );
|
|
|
+ * will rvo the object (if expression is rvo-able)
|
|
|
+ * but
|
|
|
+ * return ensures( var, condition );
|
|
|
+ * will not, instead copies
|
|
|
+ * By making _ an argument, both options will move
|
|
|
+ */
|
|
|
#define ensures( expr, cond, ... ) \
|
|
|
[ & ]( ) { \
|
|
|
decltype((expr)) _ = expr; \
|