Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Koch
dune-common
Commits
34221a8d
Commit
34221a8d
authored
15 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
implement cast to bool and reset(T*)
[[Imported from SVN: r5746]]
parent
31d97b50
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/common/shared_ptr.hh
+23
-0
23 additions, 0 deletions
dune/common/shared_ptr.hh
with
23 additions
and
0 deletions
dune/common/shared_ptr.hh
+
23
−
0
View file @
34221a8d
...
...
@@ -95,6 +95,9 @@ namespace Dune
*/
inline
void
reset
();
/** \brief Detach shared pointer and set it anew for the given pointer */
inline
void
reset
(
T
*
pointer
);
/** \brief The number of shared_ptrs pointing to the object we point to */
int
use_count
()
const
;
...
...
@@ -114,6 +117,19 @@ namespace Dune
/** @brief Destructor, deletes element_type* rep_. */
~
PointerRep
()
{
delete
rep_
;
}
}
*
rep_
;
// Needed for the implicit conversion to "bool"
private
:
typedef
T
*
shared_ptr
::
PointerRep
::*
__unspecified_bool_type
;
public
:
/** \brief Implicit conversion to "bool" */
operator
__unspecified_bool_type
()
const
// never throws
{
return
rep_
==
0
?
0
:
&
shared_ptr
::
PointerRep
::
rep_
;
}
};
template
<
class
T
>
...
...
@@ -191,6 +207,13 @@ namespace Dune
}
}
template
<
class
T
>
inline
void
shared_ptr
<
T
>::
reset
(
T
*
pointer
)
{
reset
();
rep_
=
new
PointerRep
(
pointer
);
}
/** @} */
#endif // #ifdef SHARED_PTR_NAMESPACE
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment