hatcat / cg30_issues

The public issues repository for the book "Beautiful C++"
4 stars 1 forks source link

Prefer alternative example in E6 #10

Open hatcat opened 3 years ago

hatcat commented 3 years ago

[From Arthur] Page 235 Edit#1 I skipped over the original "fopen example": you showed it using unique_ptr, right? unique_ptr is the right tool for the job in this case. As you say, unique_resource would be maybe-suited for resources that aren't pointers (aren't nullable). I think it would be better to show an example that actually wasn't a pointer and actually did require unique_resource. (Personally I doubt such examples exist, which is why unique_resource has never made it through WG21; but if you could come up with one, that'd be good, because FILE* definitely is not such an example.)