Skip to content

StEEmcClusterMaker: avoid using operator++(bool&)#274

Merged
plexoos merged 1 commit intostar-bnl:mainfrom
veprbl:pr/eemcppol_no_inc_bool
Jan 18, 2022
Merged

StEEmcClusterMaker: avoid using operator++(bool&)#274
plexoos merged 1 commit intostar-bnl:mainfrom
veprbl:pr/eemcppol_no_inc_bool

Conversation

@veprbl
Copy link
Copy Markdown
Member

@veprbl veprbl commented Jan 6, 2022

The code is roughly equivalent to:

    bool used[];
    for(;;) {
      // ...
      if (used[istrip]) break;
      // ...
      used[istrip]++;
      // ...
    }

The use of operator++ for a boolean value is not wrong, but is slightly confusing and leads to a compilation error in C++17:

.sl79_gcc485/obj/StRoot/StEEmcPool/StEEmcClusterMaker/StEEmc2x2ClusterMaker.cxx:355:16: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
  355 |    used[istrip]++;
      |                ^~
.sl79_gcc485/obj/StRoot/StEEmcPool/StEEmcClusterMaker/StEEmc2x2ClusterMaker.cxx:391:16: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
  391 |    used[istrip]++;
      |                ^~

The code is roughly equivalent to:

    bool used[];
    for(;;) {
      // ...
      if (used[istrip]) break;
      // ...
      used[istrip]++;
      // ...
    }

The use of operator++ for a boolean value is not wrong, but is slightly confusing and leads to a compilation error in C++17:

    .sl79_gcc485/obj/StRoot/StEEmcPool/StEEmcClusterMaker/StEEmc2x2ClusterMaker.cxx:355:16: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
      355 |    used[istrip]++;
          |                ^~
    .sl79_gcc485/obj/StRoot/StEEmcPool/StEEmcClusterMaker/StEEmc2x2ClusterMaker.cxx:391:16: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
      391 |    used[istrip]++;
          |                ^~
@veprbl veprbl changed the title StEEmcClusterMaker: don't try to use operator++(bool&) StEEmcClusterMaker: avoid using operator++(bool&) Jan 7, 2022
Copy link
Copy Markdown
Member

@plexoos plexoos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a yes from me 😄 Thanks!

@starsdong
Copy link
Copy Markdown
Member

Ting, does this PR look OK to you? Thanks

@starsdong
Copy link
Copy Markdown
Member

Dmitri, let us merge it and close this PR. Thanks

@plexoos
Copy link
Copy Markdown
Member

plexoos commented Jan 18, 2022

Could you hit the approve button, Xin?

@plexoos plexoos merged commit 3bc669a into star-bnl:main Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants