Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
teaching
nswi098
Cecko
skeleton
Commits
d5683d08
Commit
d5683d08
authored
Nov 17, 2020
by
Bednárek David RNDr. Ph.D.
Browse files
safe_ptr: conversion constructor to mimic pointer convertibility
parent
594aac43
Changes
1
Hide whitespace changes
Inline
Side-by-side
fmwk/ckir.hpp
View file @
d5683d08
...
...
@@ -56,6 +56,8 @@ namespace cecko {
public:
safe_ptr
()
:
p_
(
nullptr
)
{}
safe_ptr
(
std
::
nullptr_t
)
:
p_
(
nullptr
)
{}
template
<
typename
E2
,
typename
DF2
,
std
::
enable_if_t
<
std
::
is_convertible_v
<
E2
*
,
E
*
>,
bool
>
=
true
>
safe_ptr
(
const
safe_ptr
<
E2
,
DF2
>&
b
)
:
p_
(
b
.
p_
)
{}
explicit
safe_ptr
(
E
*
p
)
:
p_
(
p
)
{}
operator
E
*
()
const
{
return
p_
;
}
operator
bool
()
const
{
return
!!
p_
;
}
...
...
@@ -66,6 +68,8 @@ namespace cecko {
private:
E
*
p_
;
static
E
&
dummy
()
{
static
decltype
(
DF
()())
d
=
DF
()();
return
d
;
}
template
<
typename
E2
,
typename
DF2
>
friend
class
safe_ptr
;
};
// numbers
...
...
Write
Preview
Supports
Markdown
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