Boost logo

Boost :

From: Anthony Williams (anthwil_at_[hidden])
Date: 2002-09-12 08:18:09


I have uploaded a class template "StrongStorage" that implements the ideas I
voiced in an earlier thread about variant types for containing any object type
in a way that supports strongly exception safe assignment and swap to:

http://groups.yahoo.com/group/boost/files/strongstorage.hpp

usage is simple:

boost::StrongStorage<SomeType> ss; // empty, contains nothing
SomeType val; // some value
boost::StrongStorage<SomeType> ss2(val); // contains a copy of val

if(ss.isEmpty()) doSomething(); // check whether it contains a value
SomeType& ref=ss2.value(); // get a reference to the value

ss=ss2; // strongly-exception safe assignment
ss.swap(ss2); // strongly-exception safe swap

It uses boost::aligned_storage for the underlying storage.

Is the interface sufficient? Is it useful? Any other comments?

Anthony


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk