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

The "I regret nothing" solution #7

Open
isc30 opened this issue Sep 14, 2018 · 2 comments
Open

The "I regret nothing" solution #7

isc30 opened this issue Sep 14, 2018 · 2 comments

Comments

@isc30
Copy link

isc30 commented Sep 14, 2018

Credit: @AlexOteiza

for (auto i = 0; i < 3; i++) 
{
    X* pX = nullptr;
    
    // Begin
    
    if (i == 0)
    {
        X0 var;
        var.Process();
    }
    else if (i == 1)
    {
        X1 var;
        var.Process();
    }
    else
    {
        X2 var;
        var.Process();
    }
    
    continue; // I regret nothing
    
    // End
    
    pX->Process();
}
@isc30 isc30 changed the title the "I regret nothing" solution The "I regret nothing" solution Sep 14, 2018
@CptBread
Copy link

This is a lot less programmer horror then mine. I approve.

@amarmer
Copy link
Owner

amarmer commented Sep 14, 2018

Sure :-)

Then there is also solution:

// Begin
X0().Process();
X1().Process();
X2().Process();

break; // Or any program termination function: return, exit, ...
// End

To avoid these types of solutions description should be ... doesn't call: new, placement new, continue, break, all program termination functions ... :-)

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

No branches or pull requests

3 participants