isocpp / CppCoreGuidelines

The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Other
42.63k stars 5.43k forks source link

C.33 If a class has an owning pointer member: inconsistency in the example #610

Closed tlanc007 closed 7 years ago

tlanc007 commented 8 years ago

The example just before Note has to me a slight inconsistency:

    template
    class Smart_ptr3 {
        owner<T>* p;   // OK: explicit about ownership of *p
        // ...
    public:
        // ...
        // ... copy and move operations ...
        ~Smart_ptr3() { delete p; }
    };

Although this is legal. Wouldn't it be better, if the usage was kept consistent and the asterisk was moved inside the brackets?

*owner<T> p;**

Also the end of this section, under Enforcement owner is referred to without an asterisk. For clarity, shouldn't owner always be referred to with a type followed by an asterisk, *owner<T>**?

I am willing to submit a fix, if desired.

tlanc007 commented 8 years ago

Submitted a patch for review. Only changed the code example part.

I left the owner alone in the Enforcement section. The whole document uses this style in the text. So assuming this is the intended style for now.

AndrewPardoe commented 8 years ago

Thank you! We have merged PR #613. Thanks for isolating your PR to the parts you were certain about.

AndrewPardoe commented 7 years ago

Cleaning up and closing. Thanks again!