如何减少用户数据类型表示法?(typedef?)

How to reduce an user data type notation? (typedef?)

本文关键字:typedef 表示 何减少 用户 数据类型      更新时间:2023-10-16

我将ttmath库用于C++(大数字)。我使用2D阵列(矩阵)。例如:

#define FOR(i,a,b) for(int (i)=(a); i<(b) ; ++(i))
#define Big ttmath::Big<2, 2>
vector < vector < Big > > A(n);
FOR(i, 0, n) 
   A[i].resize(n);

其中A——一个平方矩阵NxN。但我只想要类型:

Matrix A(n);
FOR(i, 0, n) 
   A[i].resize(n)

我试着使用typedef:

typedef vector < vector < Big > > Matrix;

但它不会编译。

MS与2013:

error C2143: syntax error : missing ';' before '<'

(与typedef一致)。

整个"项目"。:)

去掉递归宏Big,改为使用typedef,类似于:

typedef ttmath::Big<2, 2> Big_type;
typedef std::vector<std::vector<Big_type> > Matrix_type;
Marix_type A(n);
FOR(i, 0, n) 
    A[i].resize(n)