Skip to content
Snippets Groups Projects
Commit 770f3ba9 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

[doc][stackobject_to_shared_ptr()] Improve documentation.

Add "@relatesalso null_deleter", this includes the documentation for the
function with null_deleter but also leaves a standalone version.  Document
what is so special about the shared_ptr the function returns.  Mention the
#include needed to get the function.
parent ab16344b
No related branches found
No related tags found
No related merge requests found
......@@ -55,11 +55,22 @@ namespace Dune
};
/**
@brief Convert a stack-allocated object to a shared_ptr:
@brief Create a shared_ptr for a stack-allocated object
@relatesalso null_deleter
@code
#include <dune/common/shared_ptr.hh>
@endcode
Usage:
@code
int i = 10;
shared_ptr<int> pi = stackobject_to_shared_ptr(i);
@endcode
The @c shared_ptr points to the object on the stack, but its deleter is
set to an instance of @c null_deleter so that nothing happens when the @c
shared_ptr is destroyed.
@sa shared_ptr, null_deleter
*/
template<typename T>
inline shared_ptr<T> stackobject_to_shared_ptr(T & t)
......@@ -68,7 +79,13 @@ namespace Dune
}
/**
@brief Convert a stack object to a shared_ptr of a base class
@brief Create a shared_ptr to a base class for a stack-allocated object
@relatesalso null_deleter
@code
#include <dune/common/shared_ptr.hh>
@endcode
Usage:
@code
class A {};
class B : public A {};
......@@ -78,6 +95,11 @@ namespace Dune
B b;
shared_ptr<A> pa = stackobject_to_shared_ptr<A>(b);
@endcode
The @c shared_ptr points to the object on the stack, but its deleter is
set to an instance of @c null_deleter so that nothing happens when the @c
shared_ptr is destroyed.
@sa shared_ptr, null_deleter
*/
template<typename T, typename T2>
inline shared_ptr<T2> stackobject_to_shared_ptr(T & t)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment