N
Noah Roberts
If you have a member function like:
void add_job(std::auto_ptr<job> new_job)
{
jobs.push_back(new_job.get());
job.release();
}
can this be said to provide the strong guarantee? We know that both
get and release have no-throw, so the only point of failure is
push_back, which will fail if there's a memory allocation issue (since
ptr = ptr can't throw either). Under such a condition nothing is
changed about the jobs container, but the new_job is destroyed.
Because something changed, new job was destroyed, when an exception
was thrown I'm tempted to say it doesn't provide the strong
guarantee. On the other hand, the interface of the function
stipulates that ownership is being transfered and so cleaning up is
the right thing to do and perhaps fits the strong guarantee.
What do you think?
void add_job(std::auto_ptr<job> new_job)
{
jobs.push_back(new_job.get());
job.release();
}
can this be said to provide the strong guarantee? We know that both
get and release have no-throw, so the only point of failure is
push_back, which will fail if there's a memory allocation issue (since
ptr = ptr can't throw either). Under such a condition nothing is
changed about the jobs container, but the new_job is destroyed.
Because something changed, new job was destroyed, when an exception
was thrown I'm tempted to say it doesn't provide the strong
guarantee. On the other hand, the interface of the function
stipulates that ownership is being transfered and so cleaning up is
the right thing to do and perhaps fits the strong guarantee.
What do you think?