<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.inkscape.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Boost_shared_pointers</id>
	<title>Boost shared pointers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.inkscape.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Boost_shared_pointers"/>
	<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;action=history"/>
	<updated>2026-04-04T21:06:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=122095&amp;oldid=prev</id>
		<title>PBS: Move to attic</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=122095&amp;oldid=prev"/>
		<updated>2023-02-04T03:29:15Z</updated>

		<summary type="html">&lt;p&gt;Move to attic&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:29, 4 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l84&quot;&gt;Line 84:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 84:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/shared_ptr.htm Full shared_ptr documentation at official Boost website]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/shared_ptr.htm Full shared_ptr documentation at official Boost website]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[http://www.boost.org/doc/libs/1_39_0/libs/ptr_container/doc/ptr_container.html Boost Pointer Container library]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*[http://www.boost.org/doc/libs/1_39_0/libs/ptr_container/doc/ptr_container.html Boost Pointer Container library]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Wiki Attic]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PBS</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=122094&amp;oldid=prev</id>
		<title>PBS: Update C++11 notice</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=122094&amp;oldid=prev"/>
		<updated>2023-02-04T03:23:53Z</updated>

		<summary type="html">&lt;p&gt;Update C++11 notice&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:23, 4 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Notice: C++11 =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Notice: C++11 =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;C++11 offers unique_ptr and shared_ptr, and should be used instead&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. Please check if we have switched to C++11 and if so, start using those. Search google for it, you'll find a lot of text about this great addition to the C++ standard&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;C++11 offers &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;tt&amp;gt;&lt;/ins&gt;unique_ptr&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt; &lt;/ins&gt;and &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;tt&amp;gt;&lt;/ins&gt;shared_ptr&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt;&lt;/ins&gt;, and should be used instead.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Boost shared pointers==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Boost shared pointers==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PBS</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=89396&amp;oldid=prev</id>
		<title>Johanengelen at 17:02, 13 November 2013</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=89396&amp;oldid=prev"/>
		<updated>2013-11-13T17:02:47Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:02, 13 November 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;= Notice: C++11 =&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;C++11 offers unique_ptr and shared_ptr, and should be used instead. Please check if we have switched to C++11 and if so, start using those. Search google for it, you'll find a lot of text about this great addition to the C++ standard.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Boost shared pointers==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Boost library is a set of peer-reviewed C++ libraries that play well with STL, and some of them are considered for inclusion in future versions of the C++ standard. They are generally regarded as well designed, useful, and powerful. They are also cross platform. All header-only Boost libraries can be used in Inkscape, since Boost is an accepted compile time dependency.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Boost library is a set of peer-reviewed C++ libraries that play well with STL, and some of them are considered for inclusion in future versions of the C++ standard. They are generally regarded as well designed, useful, and powerful. They are also cross platform. All header-only Boost libraries can be used in Inkscape, since Boost is an accepted compile time dependency.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Johanengelen</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=71059&amp;oldid=prev</id>
		<title>Tweenk: /* Shared pointers in member functions */</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=71059&amp;oldid=prev"/>
		<updated>2011-07-25T18:52:21Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Shared pointers in member functions&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:52, 25 July 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l62&quot;&gt;Line 62:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Shared pointers in member functions==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Shared pointers in member functions==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sometimes a shared pointer to the current object is needed in its member function. Boost provides a mixin template class called &amp;lt;tt&amp;gt;enable_shared_from_this&amp;lt;/tt&amp;gt;, which defines a no-argument member function called &amp;lt;tt&amp;gt;shared_from_this()&amp;lt;/tt&amp;gt;. It returns a shared pointer to &amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;. At least one instance of a shared pointer to this object must exist before the first use of this method; otherwise it has undefined results (usually crash). The best way to guarantee that this is condition met is to make the constructor protected and provide a factory method that returns a shared pointer to the newly created object.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Sometimes a shared pointer to the current object is needed in its member function. Boost provides a mixin template class called &amp;lt;tt&amp;gt;enable_shared_from_this&amp;lt;/tt&amp;gt;, which defines a no-argument member function called &amp;lt;tt&amp;gt;shared_from_this()&amp;lt;/tt&amp;gt;. It returns a shared pointer to &amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;. At least one instance of a shared pointer to this object must exist before the first use of this method; otherwise it has undefined results (usually crash). The best way to guarantee that this is condition met is to make the constructor protected and provide a factory method that returns a shared pointer to the newly created object.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  class Foo : public enable_shared_from_this&amp;lt;Foo&amp;gt; {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  class Foo : public &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;boost::&lt;/ins&gt;enable_shared_from_this&amp;lt;Foo&amp;gt; {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  public:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  public:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     void someMethod() {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     void someMethod() {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Tweenk</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=53439&amp;oldid=prev</id>
		<title>Tweenk: /* Rationale */</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=53439&amp;oldid=prev"/>
		<updated>2009-07-26T00:48:53Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Rationale&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:48, 26 July 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l7&quot;&gt;Line 7:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Rationale==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Rationale==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The memory management problem is how to guarantee that a program does not have any memory leaks. It can be solved with simple reference conuting if there are no cycles between objects. There are two approaches to solve it when :&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The memory management problem is how to guarantee that a program does not have any memory leaks. It can be solved with simple reference conuting if there are no cycles between objects. There are two approaches to solve it when :&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Garbage collection. Objects are created and left alone when no longer needed. When the memory is low, a background process kicks in and reclaims memory used by objects that can no longer be reached from the stack. This is the method used in most scripting languages, as well as Java and CLR. However, it has some drawbacks. Firstly, destructors can run at some indeterminate time after the object becomes unused, or never. This precludes using the RAII idiom. Secondly, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the &lt;/del&gt;garbage &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;collector runs can take an unknown amount of time, which can make the application unresponsive&lt;/del&gt;. Thirdly, it requires some type information to be preserved at runtime, to determine where the garbage collector should look for object references.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Garbage collection. Objects are created and left alone when no longer needed. When the memory is low, a background process kicks in and reclaims memory used by objects that can no longer be reached from the stack. This is the method used in most scripting languages, as well as Java and CLR. However, it has some drawbacks. Firstly, destructors can run at some indeterminate time after the object becomes unused, or never. This precludes using the RAII idiom. Secondly, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;there is some memory overhead associated with maintaining a &lt;/ins&gt;garbage&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-collected heap&lt;/ins&gt;. Thirdly, it requires some type information to be preserved at runtime, to determine where the garbage collector should look for object references &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;- otherwise unrelated data can alias pointers, preventing some objects from being colleted&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Shared and weak pointers. This approach uses two types of object references to break the cycles. A shared pointer will keep the pointed object in memory &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;as long as it lives&lt;/del&gt;, while a weak pointer can be used to obtain a shared pointer to the same object, but will not prevent the object from destruction. This approach requires &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;a bit &lt;/del&gt;more programming effort and adds some (negligible) overhead to each operation on the shared pointer, but makes object destruction predictable.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Shared and weak pointers. This approach uses two types of object references to break the cycles. A shared pointer will keep the pointed object in memory, while a weak pointer can be used to obtain a shared pointer to the same object, but will not prevent the object from destruction. This approach requires more programming effort and adds some (negligible) overhead to each operation on the shared pointer, but makes object destruction predictable.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The second method suits C++ &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;much &lt;/del&gt;better than garbage collection. Firstly, there is generally little to no type information present at runtime to determine where to look for pointers to objects; Garbage collectors for C++ and C must assume that all data on the stack and all contents of the objects' memory are pointers to other objects. This can cause some unused memory to never be freed, because some integer in some object happens to have the same value as some other object's address. Secondly, since the C++ standard library and other libraries frequently use the RAII idiom, many C++ objects (like &amp;lt;tt&amp;gt;std::fstream&amp;lt;/tt&amp;gt;) have non-trivial destructors. If those destructors are not run right after the object becomes unused, the program may hold on to resources it no longer uses, like file descriptors or database connections.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The second method suits C++ better than garbage collection. Firstly, there is generally little to no type information present at runtime to determine where to look for pointers to objects; Garbage collectors for C++ and C must assume that all data on the stack and all contents of the objects' memory are pointers to other objects &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(also known as conservative garbage collection)&lt;/ins&gt;. This can cause some unused memory to never be freed, because some integer in some object happens to have the same value as some other object's address. Secondly, since the C++ standard library and other libraries frequently use the RAII idiom, many C++ objects (like &amp;lt;tt&amp;gt;std::fstream&amp;lt;/tt&amp;gt;) have non-trivial destructors. If those destructors are not run right after the object becomes unused, the program may hold on to resources it no longer uses, like file descriptors or database connections&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. Finally, using tricks like storing the color of a red-black tree node in the low bit of a pointer can in theory cause objects to be collected before they become unused, bu this can be mitigated with anchoring&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Shared pointers==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Shared pointers==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Tweenk</name></author>
	</entry>
	<entry>
		<id>https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=53417&amp;oldid=prev</id>
		<title>Tweenk: Created page with 'The Boost library is a set of peer-reviewed C++ libraries that play well with STL, and some of them are considered for inclusion in future versions of the C++ standard. They are ...'</title>
		<link rel="alternate" type="text/html" href="https://wiki.inkscape.org/wiki/index.php?title=Boost_shared_pointers&amp;diff=53417&amp;oldid=prev"/>
		<updated>2009-07-20T22:28:22Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;The Boost library is a set of peer-reviewed C++ libraries that play well with STL, and some of them are considered for inclusion in future versions of the C++ standard. They are ...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The Boost library is a set of peer-reviewed C++ libraries that play well with STL, and some of them are considered for inclusion in future versions of the C++ standard. They are generally regarded as well designed, useful, and powerful. They are also cross platform. All header-only Boost libraries can be used in Inkscape, since Boost is an accepted compile time dependency.&lt;br /&gt;
&lt;br /&gt;
This short tutorial will deal with the use of Boost shared pointers. They can be used to significantly reduce the amount of code needed for efficient memory management. Shared pointers with semantics identical to Boost ones are part of the C++ Library Technical Report 1, and will be included as part of the standard library in a future revision of C++.&lt;br /&gt;
&lt;br /&gt;
If the ownership of objects is clear, investigate whether the simpler and lower overhead &amp;lt;tt&amp;gt;std::auto_ptr&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;boost::scoped_ptr&amp;lt;/tt&amp;gt; can meet your needs. If you mainly need to use &amp;lt;tt&amp;gt;shared_ptr&amp;lt;/tt&amp;gt; to put smart pointers in containers (since &amp;lt;tt&amp;gt;std::auto_ptr&amp;lt;/tt&amp;gt; cannot be used in this way), investigate Boost pointer containers like &amp;lt;tt&amp;gt;boost::ptr_list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Rationale==&lt;br /&gt;
The memory management problem is how to guarantee that a program does not have any memory leaks. It can be solved with simple reference conuting if there are no cycles between objects. There are two approaches to solve it when :&lt;br /&gt;
# Garbage collection. Objects are created and left alone when no longer needed. When the memory is low, a background process kicks in and reclaims memory used by objects that can no longer be reached from the stack. This is the method used in most scripting languages, as well as Java and CLR. However, it has some drawbacks. Firstly, destructors can run at some indeterminate time after the object becomes unused, or never. This precludes using the RAII idiom. Secondly, the garbage collector runs can take an unknown amount of time, which can make the application unresponsive. Thirdly, it requires some type information to be preserved at runtime, to determine where the garbage collector should look for object references.&lt;br /&gt;
# Shared and weak pointers. This approach uses two types of object references to break the cycles. A shared pointer will keep the pointed object in memory as long as it lives, while a weak pointer can be used to obtain a shared pointer to the same object, but will not prevent the object from destruction. This approach requires a bit more programming effort and adds some (negligible) overhead to each operation on the shared pointer, but makes object destruction predictable.&lt;br /&gt;
&lt;br /&gt;
The second method suits C++ much better than garbage collection. Firstly, there is generally little to no type information present at runtime to determine where to look for pointers to objects; Garbage collectors for C++ and C must assume that all data on the stack and all contents of the objects' memory are pointers to other objects. This can cause some unused memory to never be freed, because some integer in some object happens to have the same value as some other object's address. Secondly, since the C++ standard library and other libraries frequently use the RAII idiom, many C++ objects (like &amp;lt;tt&amp;gt;std::fstream&amp;lt;/tt&amp;gt;) have non-trivial destructors. If those destructors are not run right after the object becomes unused, the program may hold on to resources it no longer uses, like file descriptors or database connections.&lt;br /&gt;
&lt;br /&gt;
==Shared pointers==&lt;br /&gt;
Shared pointer is a smart pointer (a C++ object wih overloaded &amp;lt;tt&amp;gt;operator*()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;operator-&amp;gt;()&amp;lt;/tt&amp;gt;) that keeps a pointer to an object and a pointer to a shared reference count. Every time a copy of the smart pointer is made using the copy constructor, the reference count is incremented. When a shared pointer is destroyed, the reference count for its object is decremented. Shared pointers constructed from raw pointers initially have a reference count of 1. When the reference count reaches 0, the pointed object is destroyed, and the memory it occupies is freed. You do not need to explicitly destroy objects: it will be done automatically when the last pointer's destructor runs.&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
When creating a new object with &amp;lt;tt&amp;gt;new&amp;lt;/tt&amp;gt;, use it as a constructor argument of a &amp;lt;tt&amp;gt;boost::shared_ptr&amp;lt;/tt&amp;gt;.&lt;br /&gt;
 boost::shared_ptr&amp;lt;Foo&amp;gt; foo_ptr(new Foo());&lt;br /&gt;
You can reassign the pointer to a new object using the member function &amp;lt;tt&amp;gt;reset()&amp;lt;/tt&amp;gt;. This will decrease the reference count of the old object, if any, and reinitialize the object with the argument and a reference count of 1.&lt;br /&gt;
 foo_ptr.reset(new Foo());&lt;br /&gt;
&lt;br /&gt;
Note however that you cannot obtain a shared pointer to an object from a raw pointer. This will cause a segmentation fault:&lt;br /&gt;
 void some_function(Foo *f) {&lt;br /&gt;
    boost::shared_ptr&amp;lt;Foo&amp;gt; fptr(f);&lt;br /&gt;
    fptr-&amp;gt;something();&lt;br /&gt;
 }&lt;br /&gt;
 ...&lt;br /&gt;
 Foo *foo = new Foo();&lt;br /&gt;
 some_function(foo);&lt;br /&gt;
 foo-&amp;gt;something();&lt;br /&gt;
That's because the temporary &amp;lt;tt&amp;gt;fptr&amp;lt;/tt&amp;gt; is initialized with a reference count of 1. After the function returns, the reference count is zero and the object is destroyed. &amp;lt;tt&amp;gt;foo-&amp;gt;something()&amp;lt;/tt&amp;gt; will then fail, because &amp;lt;tt&amp;gt;foo&amp;lt;/tt&amp;gt; no longer points to a valid object.&lt;br /&gt;
&lt;br /&gt;
An uninitialized shared pointer is ''empty''. This is equivalent to NULL for raw pointers. You can check for an empty shared pointer using this code:&lt;br /&gt;
 if (foo) {&lt;br /&gt;
    // foo points to an object&lt;br /&gt;
 } else {&lt;br /&gt;
    // foo is empty&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
A raw pointer can be retrieved using the &amp;lt;tt&amp;gt;get()&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
 Foo *rawptr = fptr.get();&lt;br /&gt;
&lt;br /&gt;
==Weak pointers==&lt;br /&gt;
Weak pointers can only be used to obtain a shared pointer to the same object, and check whether the object was already destroyed. They can be used to break circular references between objects. A weak pointer that points to an object that was already destroyed is called ''expired''. Empty weak pointers (that don't point to any object) are also expired.&lt;br /&gt;
&lt;br /&gt;
Here is an example:&lt;br /&gt;
 boost::shared_ptr&amp;lt;Foo&amp;gt; foo(new Foo());&lt;br /&gt;
 boost::weak_ptr&amp;lt;Foo&amp;gt; weakfoo(foo);&lt;br /&gt;
 ...&lt;br /&gt;
 boost::shared_ptr&amp;lt;Foo&amp;gt; fptr = weakfoo.lock();&lt;br /&gt;
 if (fptr) {&lt;br /&gt;
    // object still exists&lt;br /&gt;
 } else {&lt;br /&gt;
    // object already destroyed&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Weak pointers cannot be dereferenced for thread safety reasons. If some other thread destroyed the object after you checked the weak pointer for expiry but before you used it, you would get a crash. Shared pointers can be obtained from weak pointers using use of two methods:&lt;br /&gt;
# &amp;lt;tt&amp;gt;boost::shared_ptr&amp;lt;Foo&amp;gt; fptr = weakfoo.lock();&amp;lt;/tt&amp;gt; - fptr will be empty if &amp;lt;tt&amp;gt;weakfoo&amp;lt;/tt&amp;gt; is expired. An exception will never be thrown.&lt;br /&gt;
# &amp;lt;tt&amp;gt;boost::shared_ptr&amp;lt;Foo&amp;gt; fptr(weakfoo);&amp;lt;/tt&amp;gt; - the exception &amp;lt;tt&amp;gt;std::tr1::bad_weak_ptr&amp;lt;/tt&amp;gt; will be thrown if &amp;lt;tt&amp;gt;weakfoo&amp;lt;/tt&amp;gt; is expired.&lt;br /&gt;
&lt;br /&gt;
==Shared pointers in member functions==&lt;br /&gt;
Sometimes a shared pointer to the current object is needed in its member function. Boost provides a mixin template class called &amp;lt;tt&amp;gt;enable_shared_from_this&amp;lt;/tt&amp;gt;, which defines a no-argument member function called &amp;lt;tt&amp;gt;shared_from_this()&amp;lt;/tt&amp;gt;. It returns a shared pointer to &amp;lt;tt&amp;gt;this&amp;lt;/tt&amp;gt;. At least one instance of a shared pointer to this object must exist before the first use of this method; otherwise it has undefined results (usually crash). The best way to guarantee that this is condition met is to make the constructor protected and provide a factory method that returns a shared pointer to the newly created object.&lt;br /&gt;
 class Foo : public enable_shared_from_this&amp;lt;Foo&amp;gt; {&lt;br /&gt;
 public:&lt;br /&gt;
    void someMethod() {&lt;br /&gt;
       boost::shared_ptr&amp;lt;Foo&amp;gt; this_ = shared_from_this();&lt;br /&gt;
       // use pointer...&lt;br /&gt;
    }&lt;br /&gt;
    ...&lt;br /&gt;
    static boost::shared_ptr&amp;lt;Foo&amp;gt; create() {&lt;br /&gt;
       return boost::shared_ptr&amp;lt;Foo&amp;gt;(new Foo());&lt;br /&gt;
    }&lt;br /&gt;
 protected:&lt;br /&gt;
    Foo() { ... }&lt;br /&gt;
    ...&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[http://www.boost.org/doc/libs/1_39_0/libs/smart_ptr/shared_ptr.htm Full shared_ptr documentation at official Boost website]&lt;br /&gt;
*[http://www.boost.org/doc/libs/1_39_0/libs/ptr_container/doc/ptr_container.html Boost Pointer Container library]&lt;/div&gt;</summary>
		<author><name>Tweenk</name></author>
	</entry>
</feed>