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
b84ed09e
Commit
b84ed09e
authored
Mar 10, 2012
by
Davis King
Browse files
Added is_array template.
parent
0571e1df
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
dlib/array/array_kernel.h
dlib/array/array_kernel.h
+9
-0
dlib/is_kind.h
dlib/is_kind.h
+13
-0
dlib/test/array.cpp
dlib/test/array.cpp
+5
-0
No files found.
dlib/array/array_kernel.h
View file @
b84ed09e
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
#include "../algs.h"
#include "../algs.h"
#include "../serialize.h"
#include "../serialize.h"
#include "../sort.h"
#include "../sort.h"
#include "../is_kind.h"
namespace
dlib
namespace
dlib
{
{
...
@@ -742,6 +743,14 @@ namespace dlib
...
@@ -742,6 +743,14 @@ namespace dlib
}
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
,
typename
MM
>
struct
is_array
<
array
<
T
,
MM
>
>
{
const
static
bool
value
=
true
;
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/is_kind.h
View file @
b84ed09e
...
@@ -72,6 +72,19 @@ namespace dlib
...
@@ -72,6 +72,19 @@ namespace dlib
!*/
!*/
};
};
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
is_array
:
public
default_is_kind_value
{
/*!
- if (T is an implementation of array/array_kernel_abstract.h) then
- is_array<T>::value == true
- else
- is_array<T>::value == false
!*/
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
template
<
typename
T
>
...
...
dlib/test/array.cpp
View file @
b84ed09e
...
@@ -35,6 +35,7 @@ namespace
...
@@ -35,6 +35,7 @@ namespace
{
{
dlib
::
rand
rnd
;
dlib
::
rand
rnd
;
DLIB_TEST
(
is_array
<
array
>::
value
==
true
);
array
a1
,
a2
;
array
a1
,
a2
;
...
@@ -606,6 +607,8 @@ namespace
...
@@ -606,6 +607,8 @@ namespace
a
.
push_back
(
temp
);
a
.
push_back
(
temp
);
DLIB_TEST
(
a
.
size
()
==
6
);
DLIB_TEST
(
a
.
size
()
==
6
);
DLIB_TEST
(
a
[
5
].
whatever
==
99
);
DLIB_TEST
(
a
[
5
].
whatever
==
99
);
DLIB_TEST
(
is_array
<
array
<
stuff
>
>::
value
==
true
);
}
}
...
@@ -627,6 +630,8 @@ namespace
...
@@ -627,6 +630,8 @@ namespace
// test a checking version first for good measure
// test a checking version first for good measure
print_spinner
();
print_spinner
();
array_expand_test
<
array
<
unsigned
long
>
>
();
array_expand_test
<
array
<
unsigned
long
>
>
();
DLIB_TEST
(
is_array
<
int
>::
value
==
false
);
}
}
}
a
;
}
a
;
...
...
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