---------------
Christof.Meerwald@ freec++.prog

home
> prog
>> freecpp
>>> if stmt cond

translate to German (by SYSTRAN)

If Statement Condition

> if_stmt_cond.cpp:

int Ac = 0, Ad = 0;

struct A
{
  A(bool b)
    : b (b)
  { Ac++; }

  operator bool() { return b; }

  ~A() { Ad++; }

  bool b;
};


int main()
{
  for (int i = 0; i < 2; i++)
  {
    if (A a = (i == 0))
    {
      bool b = a;
      if (! b) return 1;
      if (i != 0) return 1;
      if (Ac != (Ad + 1)) return 1;
    } else
    {
      bool b = a;
      if (b) return 1;
      if (i == 0) return 1;
      if (Ac != (Ad + 1)) return 1;
    }
    if (! (Ac == (2*i + 1) && Ad == (2*i + 1))) return 1;

    if (A a = (i != 0))
    {
      bool b = a;
      if (! b) return 1;
      if (i == 0) return 1;
      if (Ac != (Ad + 1)) return 1;
    } else
    {
      bool b = a;
      if (b) return 1;
      if (i != 0) return 1;
      if (Ac != (Ad + 1)) return 1;
    }
    if (! (Ac == (2*i + 2) && Ad == (2*i + 2))) return 1;
    int a = 0;
  }

  return 0;
}
---------------

This Web page is licensed under the Creative Commons Attribution - NonCommercial - Share Alike License. Any use is subject to the Privacy Policy.

Revision: 1.2, cmeerw.org/prog/freecpp/if_stmt_cond.html
Last modified: Mon Sep 03 18:20:50 2018
Christof Meerwald <cmeerw@cmeerw.org>
XMPP: cmeerw@cmeerw.org