Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
5a0af536
Commit
5a0af536
authored
Aug 15, 2015
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c++ move semantics for cv::Ptr<>
parent
56cdd6f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
cvdef.h
modules/core/include/opencv2/core/cvdef.h
+19
-0
cvstd.hpp
modules/core/include/opencv2/core/cvstd.hpp
+5
-0
ptr.inl.hpp
modules/core/include/opencv2/core/ptr.inl.hpp
+23
-0
No files found.
modules/core/include/opencv2/core/cvdef.h
View file @
5a0af536
...
...
@@ -228,4 +228,23 @@
# endif
#endif
/****************************************************************************************\
* C++ Move semantics *
\****************************************************************************************/
#ifndef CV_CXX_MOVE_SEMANTICS
# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER) && _MSC_VER >= 1600
# define CV_CXX_MOVE_SEMANTICS 1
# elif defined(__clang)
# if __has_feature(cxx_rvalue_references)
# define CV_CXX_MOVE_SEMANTICS 1
# endif
# endif
#else
# if CV_CXX_MOVE_SEMANTICS == 0
# undef CV_CXX_MOVE_SEMANTICS
# endif
#endif
#endif // __OPENCV_CORE_CVDEF_H__
modules/core/include/opencv2/core/cvstd.hpp
View file @
5a0af536
...
...
@@ -411,6 +411,11 @@ struct Ptr
template
<
typename
Y
>
Ptr
<
Y
>
dynamicCast
()
const
;
#ifdef CV_CXX_MOVE_SEMANTICS
Ptr
(
Ptr
&&
o
);
Ptr
&
operator
=
(
Ptr
&&
o
);
#endif
private
:
detail
::
PtrOwner
*
owner
;
T
*
stored
;
...
...
modules/core/include/opencv2/core/ptr.inl.hpp
View file @
5a0af536
...
...
@@ -252,6 +252,29 @@ Ptr<Y> Ptr<T>::dynamicCast() const
return
Ptr
<
Y
>
(
*
this
,
dynamic_cast
<
Y
*>
(
stored
));
}
#ifdef CV_CXX_MOVE_SEMANTICS
template
<
typename
T
>
Ptr
<
T
>::
Ptr
(
Ptr
&&
o
)
:
owner
(
o
.
owner
),
stored
(
o
.
stored
)
{
o
.
owner
=
NULL
;
o
.
stored
=
NULL
;
}
template
<
typename
T
>
Ptr
<
T
>&
Ptr
<
T
>::
operator
=
(
Ptr
<
T
>&&
o
)
{
release
();
owner
=
o
.
owner
;
stored
=
o
.
stored
;
o
.
owner
=
NULL
;
o
.
stored
=
NULL
;
return
*
this
;
}
#endif
template
<
typename
T
>
void
swap
(
Ptr
<
T
>&
ptr1
,
Ptr
<
T
>&
ptr2
){
ptr1
.
swap
(
ptr2
);
...
...
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