A vector containing read-only matrices?

I want to use a vector to store whole 5x5 read-only matrices

vector<const int[5][5]> startingPieces;

But this announcement causes a bunch of weird errors that I have never seen before.

error C2535: 'const int (*std::allocator<_Ty>::address(const int (&)[5][5]) const)[5][5]' : member function already defined or declared
1>        with
1>        [
1>            _Ty=const int [5][5]
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\xmemory(109) : see declaration of 'std::allocator<_Ty>::address'
1>        with
1>        [
1>            _Ty=const int [5][5]
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\vector(429) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
1>        with
1>        [
1>            _Ty=const int [5][5]
1>        ]
1>        c:\program files\microsoft visual studio 9.0\vc\include\vector(439) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
1>        with
1>        [
1>            _Ty=const int [5][5],
1>            _Alloc=std::allocator<const int [5][5]>
1>        ]
1>        c:\users\eric\documents\visual studio 2008\projects\testing grounds\testing grounds\main.cpp(14) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1>        with
1>        [
1>            _Ty=const int [5][5]
1>        ]

So what is wrong with this announcement?

+3
source share
3 answers

Here you have to create your own matrix class that stores a 5x5 data array and then create your vector with that.

+2
source

: -, const - . , , ? . -, , , , , .

+7

array ( std::array std::tr1::array; , boost::array Boost):

std::vector<std::array<std::array<int, 5> > >

, , - const; const, .

+1

Source: https://habr.com/ru/post/1750505/


All Articles