1

How do I get the value_type of the inner-most of an n-dimensional vector?

In particular, I would like to each time obtain type_name to be double for the example as follows:

#include <vector>

template <class T>
void foo(const T& data)
{
    // ??
    using type_name = typename T::value_type;

    type_name a;
}

int main()
{
    std::vector<std::vector<double>> a;
    std::vector<std::vector<std::vector<double>>> b;

    foo(a);
    foo(b);

    return 0;
}
Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
  • @NathanOliver - yes, this is a better duplicate. I thought there is an answer in my duplicate which handled the case OP asked about, but it wasn't there, while yours does have it. – SergeyA Sep 26 '19 at 17:44
  • @NathanOliver - Thanks, somehow I missed that answer in my search! – Tom de Geus Sep 27 '19 at 07:54

0 Answers0