Am 03.02.2016 um 00:21 schrieb Ali Çehreli:
On 02/02/2016 03:09 PM, Ola Fosheim Grøstad wrote:
On Tuesday, 2 February 2016 at 22:36:22 UTC, Ali Çehreli wrote:
This question has been brought up a lot lately. I've decided to look
at this more seriously yesterday.

Nice to see that others are playing around with this, I don't have time
to check your code, but one key issue with move semantics is exception
safety.

AFAICT D's "std.move" is insufficient, as it would null out the original
pointer prematurely and when an exception is thrown the resource will
disappear rather than simple remain "unmoved".


Exactly. I've saved my rear end by inserting a TODO comment just before
posting the code: :p

         /* TODO: Be exception-safe; don't destroy before succesful
          * construction. */
         if (occupied) {
             destroy_at(i);
         }

         emplace(place, args);

Ali


For std.move, isn't the only place where an exception can be thrown in the destructor (which shouldn't throw)? It uses memcpy to move the memory around to circumvent any extended construction logic.

Reply via email to