Talk:Policies/Library Code Policy: Difference between revisions

Page contents not supported in other languages.
From KDE TechBase
No edit summary
Line 6: Line 6:
::Yay, but only, if it weren't locked or you have the necessary permissions. :-P
::Yay, but only, if it weren't locked or you have the necessary permissions. :-P
::OTOH, I think, it's good, that I put my first thoughts here. The const'ness of the d-pointer prevents the default assignment of being used. --[[User:Nikolaus|nikolaus]] 12:47, 30 January 2007 (CET)
::OTOH, I think, it's good, that I put my first thoughts here. The const'ness of the d-pointer prevents the default assignment of being used. --[[User:Nikolaus|nikolaus]] 12:47, 30 January 2007 (CET)
== Const References ==
"Each object parameter that is not a basic type (int, float, bool, enum, or pointers) should be passed by reference-to-const. This is faster, because it is not required to do a copy of the object."
: How is it faster to copy a reference to a QString than to copy a pointer to a QString::Data (which is the entire non-static contents of a QString)? Someone please explain. [[User:Argonel|Argonel]] 01:03, 11 August 2007 (CEST)

Revision as of 23:03, 10 August 2007

D Pointers

It should be mentioned, that when using d-pointers, the copy constructor and assignment operator either have to be implemented correctly or they have to be forbidden. The implicit copy constructor and assignment operator copy just the value of the pointer. The pointer to the former Private data will get lost (memory leakage).

I hate to point out the obvious, but this is a wiki and you can add this information yourself as easily as comment on it. =) --Aseigo 00:49, 30 January 2007 (CET)
Yay, but only, if it weren't locked or you have the necessary permissions. :-P
OTOH, I think, it's good, that I put my first thoughts here. The const'ness of the d-pointer prevents the default assignment of being used. --nikolaus 12:47, 30 January 2007 (CET)

Const References

"Each object parameter that is not a basic type (int, float, bool, enum, or pointers) should be passed by reference-to-const. This is faster, because it is not required to do a copy of the object."

How is it faster to copy a reference to a QString than to copy a pointer to a QString::Data (which is the entire non-static contents of a QString)? Someone please explain. Argonel 01:03, 11 August 2007 (CEST)