C++ add_pointer template with array type -
i use std::add_pointer<type>
template c++ <type_traits>
header construct pointer array type.
however, following generates error
double *y[2]; std::add_pointer<double[2]>::type x; y = x; // generates error
my msvc c++ compiler shipped sdk 7.1 says
error c2440: '=' : cannot convert 'double (*)[2]' 'double *[2]' there no conversions array types, although there conversions references or pointers arrays
what miss here?
edit: want y 2d array 1 dimension 2 , other variable. intended usage is
y[i][0]
, y[i][1]
y
, x
don't have same type here.
as error message said, y
array elements of type double*
. x
pointer pointing array type double[2]
.
you might change type of y
to:
double (*y)[2]; std::add_pointer<double[2]>::type x = new double[2][2]; y = x; // use y[0][0], y[0][1], y[1][0] ... delete[] y;
Comments
Post a Comment