My class:
template < typename T >
Array<T>{};
(Source data is stored in vector)
I have an object:
Array< string > a;
a.add("test");
And I have an object:
Array< Array< string > > b;
b.add(a);
How can I check:
- Is
b[0]
an instance ofArray
(regardless of template type)? - Is
a[0]
an instance of any type exceptArray
?
If you can use C++11, creating your type traits; by example
If you can't use C++11 or newer but only C++98, you can simply write
isArray
as followsand avoid the inclusion of
type_traits
--- EDIT ---
Modified (transformed in
constexpr
)isArrayFunc()
, as suggested by Kerrek SB (thanks!).