Commit b84ed09e authored by Davis King's avatar Davis King

Added is_array template.

parent 0571e1df
......@@ -8,6 +8,7 @@
#include "../algs.h"
#include "../serialize.h"
#include "../sort.h"
#include "../is_kind.h"
namespace dlib
{
......@@ -742,6 +743,14 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
template <typename T, typename MM>
struct is_array <array<T,MM> >
{
const static bool value = true;
};
// ----------------------------------------------------------------------------------------
}
......
......@@ -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>
......
......@@ -35,6 +35,7 @@ namespace
{
dlib::rand rnd;
DLIB_TEST(is_array<array>::value == true);
array a1, a2;
......@@ -606,6 +607,8 @@ namespace
a.push_back(temp);
DLIB_TEST(a.size() == 6);
DLIB_TEST(a[5].whatever == 99);
DLIB_TEST(is_array<array<stuff> >::value == true);
}
......@@ -627,6 +630,8 @@ namespace
// test a checking version first for good measure
print_spinner();
array_expand_test<array<unsigned long> >();
DLIB_TEST(is_array<int>::value == false);
}
} a;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment