Skip to content

Why isn't the exception safety mentioned in the Reason of R.22? #2197

@Boyeong0

Description

@Boyeong0

R.22: Use make_shared() to make shared_ptrs
R.23: Use make_unique() to make unique_ptrs

The exception safety is mentioned as a reason for R.23 but not for R.22. Is it because make_shared does less in preventing memory leaks compared to make_unique or is it simply omitted?

class X {
public:
    X() { throw std::runtime_error(); }
};

void f() {
    unique_ptr<X> p1 { new X() };
    shared_ptr<X> p2 { new X() };
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions