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
0a41b3df
Commit
0a41b3df
authored
Jul 17, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11990 from alalek:clone_nodiscard_attribute
parents
f086fc5b
b0ee5d90
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
7 deletions
+27
-7
cvdef.h
modules/core/include/opencv2/core/cvdef.h
+18
-0
mat.hpp
modules/core/include/opencv2/core/mat.hpp
+5
-5
perf_mat.cpp
modules/core/perf/perf_mat.cpp
+4
-2
No files found.
modules/core/include/opencv2/core/cvdef.h
View file @
0a41b3df
...
...
@@ -406,6 +406,24 @@ Cv64suf;
#endif
/****************************************************************************************\
* CV_NODISCARD attribute *
* encourages the compiler to issue a warning if the return value is discarded (C++17) *
\****************************************************************************************/
#ifndef CV_NODISCARD
# if defined(__GNUC__)
# define CV_NODISCARD __attribute__((__warn_unused_result__)) // at least available with GCC 3.4
# elif defined(__clang__) && defined(__has_attribute)
# if __has_attribute(__warn_unused_result__)
# define CV_NODISCARD __attribute__((__warn_unused_result__))
# endif
# endif
#endif
#ifndef CV_NODISCARD
# define CV_NODISCARD
/* nothing by default */
#endif
/****************************************************************************************\
* C++ 11 *
\****************************************************************************************/
...
...
modules/core/include/opencv2/core/mat.hpp
View file @
0a41b3df
...
...
@@ -1171,7 +1171,7 @@ public:
The method creates a full copy of the array. The original step[] is not taken into account. So, the
array copy is a continuous array occupying total()*elemSize() bytes.
*/
Mat
clone
()
const
;
Mat
clone
()
const
CV_NODISCARD
;
/** @brief Copies the matrix to another one.
...
...
@@ -2262,7 +2262,7 @@ public:
Mat_
row
(
int
y
)
const
;
Mat_
col
(
int
x
)
const
;
Mat_
diag
(
int
d
=
0
)
const
;
Mat_
clone
()
const
;
Mat_
clone
()
const
CV_NODISCARD
;
//! overridden forms of Mat::elemSize() etc.
size_t
elemSize
()
const
;
...
...
@@ -2441,7 +2441,7 @@ public:
static
UMat
diag
(
const
UMat
&
d
);
//! returns deep copy of the matrix, i.e. the data is copied
UMat
clone
()
const
;
UMat
clone
()
const
CV_NODISCARD
;
//! copies the matrix content to "m".
// It calls m.create(this->size(), this->type()).
void
copyTo
(
OutputArray
m
)
const
;
...
...
@@ -2736,7 +2736,7 @@ public:
SparseMat
&
operator
=
(
const
Mat
&
m
);
//! creates full copy of the matrix
SparseMat
clone
()
const
;
SparseMat
clone
()
const
CV_NODISCARD
;
//! copies all the data to the destination matrix. All the previous content of m is erased
void
copyTo
(
SparseMat
&
m
)
const
;
...
...
@@ -2973,7 +2973,7 @@ public:
SparseMat_
&
operator
=
(
const
Mat
&
m
);
//! makes full copy of the matrix. All the elements are duplicated
SparseMat_
clone
()
const
;
SparseMat_
clone
()
const
CV_NODISCARD
;
//! equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type)
void
create
(
int
dims
,
const
int
*
_sizes
);
//! converts sparse matrix to the old-style CvSparseMat. All the elements are copied
...
...
modules/core/perf/perf_mat.cpp
View file @
0a41b3df
...
...
@@ -61,7 +61,8 @@ PERF_TEST_P(Size_MatType, Mat_Clone,
TEST_CYCLE
()
{
source
.
clone
();
Mat
tmp
=
source
.
clone
();
(
void
)
tmp
;
}
destination
=
source
.
clone
();
...
...
@@ -88,7 +89,8 @@ PERF_TEST_P(Size_MatType, Mat_Clone_Roi,
TEST_CYCLE
()
{
roi
.
clone
();
Mat
tmp
=
roi
.
clone
();
(
void
)
tmp
;
}
destination
=
roi
.
clone
();
...
...
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