On Thursday, January 24, 2019 at 7:05:40 AM UTC-5, Thiago Adams wrote:
> On Wednesday, January 23, 2019 at 6:32:39 PM UTC-2, Daniel wrote:
> > Consider:
> >
> > struct A
> > {
> > A(int i)
> > {
> > if (i % 2)
> > {
> > throw std::invalid_argument("Don't like odd!");
> > }
> > }
> > A(const A&) = default;
> > A(A&&) = default;
> > A& operator=(const A&) = default;
> > A& operator=(A&&) = default;
> > };
> >
> > struct C
> > {
> > std::vector<A> v_;
> > std::vector<int> w_;
> >
> > void push_back(int i)
> > {
> > if (w_.size()+1 < w_.capacity())
Yes, I know. The question isn't about std::vector, but about C, which
contains two std:vectors. Strong exception guarantee for C would mean
if an operation on either vector resulted in an exception, both vectors
would be in their original state. The question is: does C as I've
written it (with Alf's correction of my typo) satisfy the strong
exception guarantee?
Daniel