mirror of
https://github.com/boostorg/contract.git
synced 2026-02-27 17:02:15 +00:00
started to program macros to expand constrated class and function code
This commit is contained in:
30
test/code/class.cpp
Normal file
30
test/code/class.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
#include <boost/contract.hpp>
|
||||
#include <vector>
|
||||
|
||||
template< typename T, class Alloc >
|
||||
struct pushable {
|
||||
virtual ~pushable ( ) { }
|
||||
virtual void push_back ( T const& value ) = 0;
|
||||
};
|
||||
|
||||
BOOST_CONTRACT_CLASS(
|
||||
template( typename T, class Alloc, default std::allocator<T> )
|
||||
class (vector) extends( public (pushable<T, Alloc>) )
|
||||
) {
|
||||
BOOST_CONTRACT_CLASS_INVARIANT_TPL()
|
||||
|
||||
BOOST_CONTRACT_FUNCTION_TPL(
|
||||
public void (push_back) ( (T const&) value )
|
||||
) {
|
||||
vector_.push_back(value);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<T, Alloc> vector_;
|
||||
}
|
||||
|
||||
int main ( ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user