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.4k stars 5.42k forks source link

R.3: A raw pointer (a T*) is non-owning -- typos regarding owner #609

Closed tlanc007 closed 8 years ago

tlanc007 commented 8 years ago

The third example (just before Exceptions) reads:

    template
    class X2 {
        // ...
    public:
        owner<T> p ;   // OK: p is owning
        T* q;         // OK: q is not owning
    };

Shouldn't there be an asterisk with the T to make it an pointer? *owner<T> p**;

In this section there are a number of places in the text where owner is given without the asterisk. For example in Note. For consistency, shouldn't the asterisk be considered a part of the owner notation? So the two cases in Note should be changed to read *owner<T>**.

For a moment, this section made me think that the asterisk was a part of the template definition in the GSL. Which is not the case.

If this seems reasonable, I am willing to make the pull request and submit the fix

MikeGitb commented 8 years ago

I agree that this is confusing and should be fixed at least for the cases, where T* and owner occur next to each other. In particular, as raw pointer types are - I believe - currently the only standard types for which owner is meaningful (contrary to notnull)

tlanc007 commented 8 years ago

So in this case, only the owner in the code block should be changed and leave the two instances in the Note section as they are?

MikeGitb commented 8 years ago

Sorry, if I wasn't clear: No, I think all instances of owner<T> should be changed to owner<T*>.

Altough I'm not 100% sure that owner is actually limited to raw pointer types, I can't think of a different type for which it would make sense right now.

tlanc007 commented 8 years ago

A patch has been submitted and merged. Closing this out.