I don't entirely see how that would make a multidimensional vector. A vector<T, 2> **is a** vector<T, 1> **is a **vector<T>.

Perhaps something like that, where a multivector<T, x> is a vector<multivector<T, x - 1> >?

Code:

#include <vector>
template <class T, unsigned D>
class multivector;
namespace detail {
//metaclasses to determine parent of multivector<T, D>
template <class T, unsigned D>
struct mv_parent
{
typedef std::vector<multivector<T, D - 1> > type;
};
template <class T>
struct mv_parent<T, 1>
{
typedef std::vector<T> type;
};
template <class T>
struct mv_parent<T, 0>; //no such type
}
template <class Type, unsigned Dimensions>
class multivector: private detail::mv_parent<Type, Dimensions>::type //private inheritance as recommended
{
public:
typedef typename detail::mv_parent<Type, Dimensions>::type StorageType;
typedef typename StorageType::size_type size_type;
typedef typename StorageType::value_type value_type;
typedef typename StorageType::iterator iterator;
typedef typename StorageType::const_iterator const_iterator;
typedef typename StorageType::reverse_iterator reverse_iterator;
typedef typename StorageType::const_reverse_iterator const_reverse_iterator;
//+ some other typedefs
multivector() {}
explicit multivector ( size_type n, const value_type& value = value_type()):
StorageType(n, value)
{}
template <class InputIterator>
multivector ( InputIterator first, InputIterator last ):
StorageType(first, last)
{}
//expose all methods
using StorageType::begin;
using StorageType::end;
using StorageType::rbegin;
using StorageType::rend;
using StorageType::size;
using StorageType::max_size;
using StorageType::resize;
using StorageType::capacity;
using StorageType::empty;
using StorageType::reserve;
using StorageType::operator[];
using StorageType::at;
using StorageType::front;
using StorageType::back;
using StorageType::assign;
using StorageType::push_back;
using StorageType::pop_back;
using StorageType::insert;
using StorageType::erase;
using StorageType::swap;
using StorageType::clear;
};
#include <iostream>
int main()
{
multivector<int, 2> mvec;
mvec.push_back(multivector<int, 1>(2, 3));
mvec.push_back(multivector<int, 1>(4, 7));
for (multivector<int, 2>::size_type i = 0; i != mvec.size(); ++i) {
for (multivector<int, 1>::size_type j = 0; j != mvec.at(i).size(); ++j) {
std::cout << mvec[i][j] << ' ';
}
std::cout << '\n';
}
}