using decltype w/ parameter pack for C++11

I’m trying to get the multi_index_t code from the second answer here answered by davidhigh to work with C++11. C++11 does not support auto& type returns.

I converted the return types for the class, but I don’t understand how/if it’s possible to support the helper function multi_index without using C++14.

The code:

#include

template
struct multi_index_t
{
  std::array size_array;
  template
  multi_index_t(Args&& ... args) : size_array(std::forward(args) ...) {}

  struct iterator
  {
    struct sentinel_t {};
    std::array index_array = {};
    std::array const& size_array;
    bool _end = false;

    iterator(std::array const& size_array) : size_array(size_array) {}

    iterator& operator++() 
    {
      for (int i = 0;i < dim;++i)
      {
        if (index_array[i] < size_array[i] - 1)
        {
          ++index_array[i];
          for (int j = 0;j < i;++j) { index_array[j] = 0; }
          return *this;
        }
      }
      _end = true;
      return *this;
    }
    std::array& operator*()  { return index_array; }
    bool operator!=(sentinel_t) const { return !_end; }
  };

  iterator begin() const { return iterator{ size_array }; }
  iterator end() const { return typename iterator::sentinel_t{}; }
};


template
auto multi_index(index_t&& ... index) // <-- this doesn't compile
{
  static constexpr int size = sizeof ... (index_t); 
  auto ar = std::array{std::forward(index) ...};
  return multi_index_t(ar);
}

According to this answer, you can’t recursively expand the variadic function template via decltype. Any ideas?

All topic