Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
mantidproject
mantid
Commits
62f8065e
Commit
62f8065e
authored
6 years ago
by
Gigg, Martyn Anthony
Browse files
Options
Downloads
Patches
Plain Diff
Only test for destroyed status in debug builds
Refs #0
parent
1520c311
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/Kernel/inc/MantidKernel/SingletonHolder.h
+9
-4
9 additions, 4 deletions
Framework/Kernel/inc/MantidKernel/SingletonHolder.h
with
9 additions
and
4 deletions
Framework/Kernel/inc/MantidKernel/SingletonHolder.h
+
9
−
4
View file @
62f8065e
...
@@ -67,15 +67,20 @@ template <typename T> struct CreateUsingNew {
...
@@ -67,15 +67,20 @@ template <typename T> struct CreateUsingNew {
/// already exist
/// already exist
/// Creation is done using the CreateUsingNew policy at the moment
/// Creation is done using the CreateUsingNew policy at the moment
template
<
typename
T
>
inline
T
&
SingletonHolder
<
T
>::
Instance
()
{
template
<
typename
T
>
inline
T
&
SingletonHolder
<
T
>::
Instance
()
{
// Local static instance initialized by an immediately invoked lambda.
// Local static instance initialized by an immediately invoked lambda.
// A second nested lambda captures the singleton instance pointer
// A second nested lambda captures the singleton instance pointer
// and forms the deleter function that is registered with
// and forms the deleter function that is registered with
// the atexit deleters.
// the atexit deleters.
#ifndef NDEBUG
static
bool
destroyed
(
false
);
static
bool
destroyed
(
false
);
#endif
static
T
*
instance
=
[]
{
static
T
*
instance
=
[]
{
auto
*
singleton
=
CreateUsingNew
<
T
>::
create
();
auto
*
singleton
=
CreateUsingNew
<
T
>::
create
();
deleteOnExit
(
deleter_t
([
singleton
]()
{
deleteOnExit
(
deleter_t
([
singleton
]()
{
#ifndef NDEBUG
destroyed
=
true
;
destroyed
=
true
;
#endif
CreateUsingNew
<
T
>::
destroy
(
singleton
);
CreateUsingNew
<
T
>::
destroy
(
singleton
);
}));
}));
return
singleton
;
return
singleton
;
...
...
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