Difference between revisions of "Uno/Cpp/Snippet/Dereference a WeakReference"
From Apache OpenOffice Wiki
SergeMoutou (Talk | contribs) m |
m |
||
Line 1: | Line 1: | ||
− | < | + | <syntaxhighlight lang="cpp"> |
class A | class A | ||
{ | { | ||
Line 19: | Line 19: | ||
} | } | ||
}; | }; | ||
− | </ | + | </syntaxhighlight> |
<noinclude>[[Category:Snippet]][[Category:Uno]][[Category:Cpp]][[Category:Uno:Cpp:Snippet]]</noinclude> | <noinclude>[[Category:Snippet]][[Category:Uno]][[Category:Cpp]][[Category:Uno:Cpp:Snippet]]</noinclude> |
Latest revision as of 10:00, 19 May 2021
class A { private: WeakReference< XInputStream > m_wrStream; void set( const Reference< XInputStream > &r ) { // store to weak reference m_wrStream = r; } Reference< XInputStream > get() { // try to make the weak reference hard Reference< XIntputStream > r = m_wrStream; // Note : r.is() may be true or not, depending on whether // the object has been destroyed before. return r; } };