Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
075bf877
Commit
075bf877
authored
Aug 16, 2017
by
Ronan
Browse files
fix(Singleton): better code
parent
e4415e9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
16 deletions
+2
-16
src/object/singleton.h
src/object/singleton.h
+2
-16
No files found.
src/object/singleton.h
View file @
075bf877
...
...
@@ -31,31 +31,17 @@ public:
virtual
~
Singleton
()
=
default
;
static
T
*
getInstance
()
{
if
(
!
mInstance
)
{
mInstance
=
new
T
();
static
SingletonDeleter
deleter
;
}
return
mInstance
;
static
T
instance
;
return
&
instance
;
}
protected:
explicit
Singleton
(
ObjectPrivate
&
p
)
:
Object
(
p
)
{}
private:
struct
SingletonDeleter
{
~
SingletonDeleter
()
{
delete
mInstance
;
}
};
static
T
*
mInstance
;
L_DISABLE_COPY
(
Singleton
);
};
template
<
class
T
>
T
*
Singleton
<
T
>::
mInstance
=
nullptr
;
LINPHONE_END_NAMESPACE
#endif // ifndef _SINGLETON_H_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment