Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Thank you for your kind help! Both ways seem very elegant to me. For static bool flagInit = doInit(), false; I am not familiar with the grammar here. Could you throw me a link maybe? Commented Jun 11, 2020 at 5:41
  • 1
    @charliepu123, It's using the comma operator. You need some kind of value there because it's initialization, but doInit could return void, so this ensures there's some value. The type and actual value don't matter since you'll never need to use that variable after. With that said, in C++17, I'd personally go for [[maybe_unused]] static bool _ = doInit(), false; or something similar since it puts aside the name and makes it clear the variable is deliberate. Commented Jun 11, 2020 at 5:44