pointer check in unit tests

Stephan Bergmann sbergman at redhat.com
Wed Nov 4 10:51:18 UTC 2020


On 04/11/2020 11:35, Mike Kaganski wrote:
> On 04.11.2020 12:51, Stephan Bergmann wrote:
>> On 04/11/2020 08:26, Miklos Vajna wrote:
>>> If a never-nullptr pointer is returned, it would be really useful to
>>> somehow state that in the function's signature. Are you aware of any way
>>> to do that? There is C's __attribute__((nonnull)), but it only works on
>>> function parameters, I think.
>>
>> see "not_null" at 
>> <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines>
> 
> The note in F.60 that reads:
> 
>> Note If you prefer the pointer notation (-> and/or * vs. .), 
>> not_null<T*> provides the same guarantee as T&.
> 
> looks to me as if T& still *does* mean "pointer, but not null, with a 
> special syntax".

...the same guarantee that "no argument" is not a valid option, is 
presumably what that note wants to express in the context of "F.60: 
Prefer T* over T& when 'no argument' is a valid option".

That a reference is something completely different than a pointer shows 
e.g. in the rule that if a class has an implicit copy constructor and a 
non-static data member of reference type, then the copy constructor is 
defined as deleted (while there is no such rule if the data member is of 
pointer type).



More information about the LibreOffice mailing list