...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::contract::old_ptr — Old value pointer that requires the pointed old value type to be copyable.
// In header: <boost/contract/old.hpp> template<typename T> class old_ptr { public: // types typedef T element_type; // Pointed old value type. // construct/copy/destruct old_ptr(); // public member functions T const & operator*() const; T const *const operator->() const; explicit operator bool() const; };
This is set to point to an actual old value copy using either BOOST_CONTRACT_OLDOF
or boost::contract::make_old
(that is why this class does not have public non-default constructors):
class u { public: virtual void f(..., boost::contract::virtual_* v = 0) { boost::contract::old_ptr<old_type> old_var = BOOST_CONTRACT_OLDOF(v, old_expr); ... } ... };
See Also:
typename T
Type of the pointed old value. This type must be copyable (i.e., boost::contract::is_old_value_copyable<T>::value
is true
), otherwise this pointer will always be null and this library will generate a compile-time error when the pointer is dereferenced.
old_ptr
public member functionsT const & operator*() const;Dereference this old value pointer.
This will generate a run-time error if this pointer is null and a compile-time error if the pointed type T
is not copyable (i.e., if boost::contract::is_old_value_copyable<T>::value
is false
).
Returns: |
The pointed old value. Contract assertions should not change the state of the program so this member function is |
T const *const operator->() const;Structure-dereference this old value pointer.
This will generate a compile-time error if the pointed type T
is not copyable (i.e., if boost::contract::is_old_value_copyable<T>::value
is false
).
Returns: |
A pointer to the old value (null if this old value pointer is null). Contract assertions should not change the state of the program so this member function is |
explicit operator bool() const;Check if this old value pointer is null or not.
(This is implemented using safe-bool emulation on compilers that do not support C++11 explicit type conversion operators.)
Returns: |
True if this pointer is not null, false otherwise. |