Added is_array template.

This commit is contained in:
Davis King 2012-03-10 15:20:16 -05:00
parent 0571e1df51
commit b84ed09e55
3 changed files with 27 additions and 0 deletions

View File

@ -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;
};
// ----------------------------------------------------------------------------------------
}

View File

@ -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>

View File

@ -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;