Subject: Re: [boost] boost::variant and "Current Approach: Temporary HeapBackup" vs "An Initial Solution: Double Storage"
From: Peter Foelsche (peter_foelsche_at_[hidden])
Date: 2009-09-30 17:33:00


"Peter Foelsche" <peter_foelsche_at_[hidden]> wrote in message
news:ha0hv5$7sj$1_at_ger.gmane.org...
> 1)
> boost::variant and "Current Approach: Temporary Heap Backup" vs "An
> Initial Solution: Double Storage"
> Please provide both solutions. A potential heap allocation may prevent
> certain application areas.

from the documentation:

1) Copy-construct the content of the left-hand side to the heap; call the
pointer to this data backup.
2) Destroy the content of the left-hand side.
3) Copy-construct the content of the right-hand side in the (now-empty)
storage of the left-hand side.
4) In the event of failure, copy backup to the left-hand side storage.

step 4 may throw too in which case the variant is corrupted.

I think only when providing double storage exception safety can be
guaranteed.

5) In the event of success, deallocate the data pointed to by backup.