Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Struct template is_old_value_copyable

boost::contract::is_old_value_copyable — Trait to check if an old value type can be copied or not.


// In header: <boost/contract/old.hpp>

template<typename T> 
struct is_old_value_copyable : public boost::is_copy_constructible< T > {


By default, this unary boolean meta-function is equivalent to boost::is_copy_constructible<T> but programmers can chose to specialize it for user-defined types (in general some kind of specialization is also needed on compilers that do not support C++11, see boost::is_copy_constructible):

class u; // Some user-defined type for which old values shall not be copied.

namespace boost { namespace contract {
    template<> // Specialization to not copy old values of type `u`.
    struct is_old_value_copyable<u> : boost::false_type {};
} } // namespace

A given old value type T is copied only if boost::contract::is_old_value_copyable<T>::value is true. A copyable old value type V is always copied using boost::contract::old_value_copy<V>. A non-copyable old value type W generates a compile-time error when boost::contract::old_ptr<W> is dereferenced, but instead leaves boost::contract::old_ptr_if_copyable<W> always null (without generating compile-time errors).

See Also:

Old Value Requirements