I'm having problem with deducing a type of a single element of an c++ array.
I would like to do achieve something like:
template <class T>
struct array_element { };
template <class T>
struct array_element<T[]> {
using type = T;
};
int main() {
int a[5] = {1, 2, 3, 4, 5};
array_element<decltype(a)>::type element = a[0];
}
But the code obviously does not compile (the int[5] does not match T[])...
Aucun commentaire:
Enregistrer un commentaire