0

I am trying to detect static arrays from within a template, but I do not know if that is possible.

The following:

...
template<class T> struct _T<T[]> { ...

Is never hit, unless the array is uninitialized.

The following:

...
template<class T> struct _T<T[1]> { ...

Is only hit if the array contains 1 element.

And so on...

Is there some way to be able to capture all cases when a bracketed array is passed?

Hjkl
  • 59
  • 6
  • 1
    https://stackoverflow.com/questions/33234979/how-to-write-a-template-function-that-takes-an-array-and-an-int-specifying-array ? – Algirdas Preidžius Jun 16 '20 at 15:05
  • Yep. That's it. Thanks, bro – Hjkl Jun 16 '20 at 15:09
  • @Hjkl, are you trying to find out the type of the elements of the array and the size of the array from the template parameter(s)? – R Sahu Jun 16 '20 at 15:23
  • Well I can dedude that easily, I just wanted to check if a certain type was an array so I can then call it like this: `if(_T::is_array == true)` – Hjkl Jun 16 '20 at 15:27

0 Answers0