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

make_unique_resource_checked exception safety #10

Open
ghost opened this issue Oct 29, 2018 · 0 comments
Open

make_unique_resource_checked exception safety #10

ghost opened this issue Oct 29, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2018

Unlike std::make_unique which does not allow the passing of a custom deleter, this factory does. A deleter whose construction can throw would leak like in the following contrived test case:

int x = 1;

struct S {
    S () { throw 0; }
    void operator() (int) const { x = 0; }
};

int main () {
    try {
        stdx::make_unique_resource_checked (x, 0, S{ });
    }
    catch (...) {
        assert (0 == x);
    }

    return 0;
}

The assertion fails. One could amend the specification to ask that the deleter construction doesn't throw, along the lines of a similar specification for the deleter of std::unique_ptr (e.g., 32.11.1.2.1p5). Is this something that popped up in the previous discussions you had in LWG?

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

0 participants