Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
d88b2575
"git@developer.sourcefind.cn:OpenDAS/dlib.git" did not exist on "d7b8dfbc0c0872d525568ccd2cdcc5398209fe5a"
Commit
d88b2575
authored
Jan 20, 2020
by
Davis King
Browse files
Make copying non-const cuda_data_ptrs to const ones nicer.
parent
bd6994cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
dlib/cuda/cuda_data_ptr.h
dlib/cuda/cuda_data_ptr.h
+13
-0
No files found.
dlib/cuda/cuda_data_ptr.h
View file @
d88b2575
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#include <memory>
#include <memory>
#include <vector>
#include <vector>
#include <type_traits>
namespace
dlib
namespace
dlib
{
{
...
@@ -203,6 +204,16 @@ namespace dlib
...
@@ -203,6 +204,16 @@ namespace dlib
pdata
=
cuda_data_void_ptr
(
n
*
sizeof
(
T
));
pdata
=
cuda_data_void_ptr
(
n
*
sizeof
(
T
));
}
}
cuda_data_ptr
(
const
cuda_data_ptr
<
typename
std
::
remove_const
<
T
>::
type
>
&
other
)
:
num
(
other
.
num
),
pdata
(
other
.
pdata
)
{}
/*!
ensures
- *this is a copy of other. This version of the copy constructor allows
assigning non-const pointers to const ones. For instance, converting from
cuda_data_ptr<float> to cuda_data_ptr<const float>.
!*/
T
*
data
()
{
return
(
T
*
)
pdata
.
data
();
}
T
*
data
()
{
return
(
T
*
)
pdata
.
data
();
}
const
T
*
data
()
const
{
return
(
T
*
)
pdata
.
data
();
}
const
T
*
data
()
const
{
return
(
T
*
)
pdata
.
data
();
}
...
@@ -237,6 +248,8 @@ namespace dlib
...
@@ -237,6 +248,8 @@ namespace dlib
friend
cuda_data_ptr
<
U
>
static_pointer_cast
(
const
cuda_data_void_ptr
&
ptr
);
friend
cuda_data_ptr
<
U
>
static_pointer_cast
(
const
cuda_data_void_ptr
&
ptr
);
template
<
typename
U
>
template
<
typename
U
>
friend
cuda_data_ptr
<
U
>
static_pointer_cast
(
const
cuda_data_void_ptr
&
ptr
,
size_t
num
);
friend
cuda_data_ptr
<
U
>
static_pointer_cast
(
const
cuda_data_void_ptr
&
ptr
,
size_t
num
);
template
<
typename
U
>
friend
class
cuda_data_ptr
;
size_t
num
=
0
;
size_t
num
=
0
;
cuda_data_void_ptr
pdata
;
cuda_data_void_ptr
pdata
;
...
...
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