cpgf library documentation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
document:gvariant.html [2013/07/20 13:37]
qi [GVariant memory management and avoid memory leak]
document:gvariant.html [2017/03/11 08:42] (current)
qi [Rule 5, By default, casting a GVariant to reference-to-const (const T &) will not perform implicit type conversion.]
Line 138: Line 138:
  
 A temporary std::string will be create to hold s, then assign it to rs. A temporary std::string will be create to hold s, then assign it to rs.
 +
 +<WRAP tip>
 +How does VarantCastCopyConstRef work?
 +
 +A usual fromVariant<​const std::string &> without VarantCastCopyConstRef will return "const std::string &",​ but when VarantCastCopyConstRef is used, fromVariant will return std::string instead of a reference, which a temporary object is returned.
 +
 +In pseudo code
 +<code cpp>
 +const std::string & fromVariant<​const std::string &>​(variant);​
 +std::string fromVariant<​const std::string &, VarantCastCopyConstRef>​(variant);​
 +</​code>​
 +
 +</​WRAP>​
  
 ==== Rule 6, Setting a reference to fundamental (such as int &, double &) to variant will cause the value is copied instead of reference. ==== ==== Rule 6, Setting a reference to fundamental (such as int &, double &) to variant will cause the value is copied instead of reference. ====