Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES.22 - Additional example possibly required #1400

Closed
shieldfoss opened this issue Apr 4, 2019 · 4 comments
Closed

ES.22 - Additional example possibly required #1400

shieldfoss opened this issue Apr 4, 2019 · 4 comments
Assignees
Labels

Comments

@shieldfoss
Copy link

ES.22 repeats the (good) advice to avoid uninitialized variables, but the second example shows a use case with SomeLargeVariable where it appears hard to avoid. The example from ES.20 with widgets i and j could possibly be linked as a demonstration of how to re-work this type of problem.

@hsutter
Copy link
Contributor

hsutter commented Apr 4, 2019

Editors call: Thanks, we'll look at improving this.

@hsutter
Copy link
Contributor

hsutter commented Apr 4, 2019

Here's an example where this comes up all the time:

array<byte,K> buffer;
if (cond)
    fill_from_database(buffer);
else
    fill_with_default_values(buffer);

@shieldfoss
Copy link
Author

Having read further, it appears ES.28 provides some relevant guidance for complex initialization.

BjarneStroustrup added a commit that referenced this issue Dec 8, 2019
@BjarneStroustrup
Copy link
Contributor

example added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants