Specializing a Template Alias Inside a Template

Viewed 27

I have a matrix class as follows.

template <typename T, std::size_t M, std::size_t N> 
class Matrix
{
  std::array<std::array<T, N>, M> data_;
};

I want to create a row alias inside this matrix for ease similar to

template <typename T, std::size_t M, std::size_t N> 
class Matrix
{
  template<>
  using row = std::array<T, N>;

  std::array<row, M> data_;
};

My compiler tells me that this alias is still unspecialized though. How do I accomplish this?

1 Answers

This compiles for me:

#include <array>

template <typename T, std::size_t M, std::size_t N>
class Matrix
{
    using row = std::array<T, N>;

    std::array<row, M> data_;
};

This is not really specialization, just an ordinary using alias definition.

Related