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
c1252a10
Commit
c1252a10
authored
Jan 28, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3648 from SpecLad:get_policy-ts
parents
3bfe4f71
c481e06e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
any.h
modules/flann/include/opencv2/flann/any.h
+25
-11
No files found.
modules/flann/include/opencv2/flann/any.h
View file @
c1252a10
...
...
@@ -150,13 +150,27 @@ SMALL_POLICY(bool);
#undef SMALL_POLICY
/// This function will return a different policy for each type.
template
<
typename
T
>
base_any_policy
*
get_policy
()
template
<
typename
T
>
class
SinglePolicy
{
SinglePolicy
();
SinglePolicy
(
const
SinglePolicy
&
other
);
SinglePolicy
&
operator
=
(
const
SinglePolicy
&
other
);
public
:
static
base_any_policy
*
get_policy
();
private
:
static
typename
choose_policy
<
T
>::
type
policy
;
return
&
policy
;
}
};
template
<
typename
T
>
typename
choose_policy
<
T
>::
type
SinglePolicy
<
T
>::
policy
;
/// This function will return a different policy for each type.
template
<
typename
T
>
inline
base_any_policy
*
SinglePolicy
<
T
>::
get_policy
()
{
return
&
policy
;
}
}
// namespace anyimpl
struct
any
...
...
@@ -170,26 +184,26 @@ public:
/// Initializing constructor.
template
<
typename
T
>
any
(
const
T
&
x
)
:
policy
(
anyimpl
::
get_policy
<
anyimpl
::
empty_any
>
()),
object
(
NULL
)
:
policy
(
anyimpl
::
SinglePolicy
<
anyimpl
::
empty_any
>::
get_policy
()),
object
(
NULL
)
{
assign
(
x
);
}
/// Empty constructor.
any
()
:
policy
(
anyimpl
::
get_policy
<
anyimpl
::
empty_any
>
()),
object
(
NULL
)
:
policy
(
anyimpl
::
SinglePolicy
<
anyimpl
::
empty_any
>::
get_policy
()),
object
(
NULL
)
{
}
/// Special initializing constructor for string literals.
any
(
const
char
*
x
)
:
policy
(
anyimpl
::
get_policy
<
anyimpl
::
empty_any
>
()),
object
(
NULL
)
:
policy
(
anyimpl
::
SinglePolicy
<
anyimpl
::
empty_any
>::
get_policy
()),
object
(
NULL
)
{
assign
(
x
);
}
/// Copy constructor.
any
(
const
any
&
x
)
:
policy
(
anyimpl
::
get_policy
<
anyimpl
::
empty_any
>
()),
object
(
NULL
)
:
policy
(
anyimpl
::
SinglePolicy
<
anyimpl
::
empty_any
>::
get_policy
()),
object
(
NULL
)
{
assign
(
x
);
}
...
...
@@ -214,7 +228,7 @@ public:
any
&
assign
(
const
T
&
x
)
{
reset
();
policy
=
anyimpl
::
get_policy
<
T
>
();
policy
=
anyimpl
::
SinglePolicy
<
T
>::
get_policy
();
policy
->
copy_from_value
(
&
x
,
&
object
);
return
*
this
;
}
...
...
@@ -269,7 +283,7 @@ public:
void
reset
()
{
policy
->
static_delete
(
&
object
);
policy
=
anyimpl
::
get_policy
<
anyimpl
::
empty_any
>
();
policy
=
anyimpl
::
SinglePolicy
<
anyimpl
::
empty_any
>::
get_policy
();
}
/// Returns true if the two types are the same.
...
...
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