These two arrays
array<array<bool,19>,19> tablero
and
array<array<int,19>,19> lab;
have different types and there is no implicit conversion from one array to another.
You can either write loops yourself or use some standard algorithms as it is shown in this demonstrative program
#include <iostream>
#include <array>
#include <algorithm>
#include <numeric>
int main()
{
std::array<std::array<bool,19>,19> tablero;
std::array<std::array<int,19>,19> tablero1;
std::accumulate( tablero.begin(), tablero.end(), tablero1.begin(),
[]( auto it, const auto &a )
{
return std::copy( a.begin(), a.end(), it->begin() ), ++it;
} );
return 0;
}
Your compiler has to support specifier auto in lambda expressions that the code would compile.
Or the same program but with some output
#include <iostream>
#include <iomanip>
#include <array>
#include <algorithm>
#include <numeric>
int main()
{
const size_t N = 3;
std::array<std::array<bool, N>, N> tablero =
{
{
{ true, false, false },
{ false, true, false },
{ false, false, true }
}
};
std::array<std::array<int, N>, N> tablero1;
std::accumulate( tablero.begin(), tablero.end(), tablero1.begin(),
[]( auto it, const auto &a )
{
return std::copy( a.begin(), a.end(),it->begin() ), ++it;
} );
for ( const auto &a : tablero )
{
for ( auto b : a ) std::cout << std::boolalpha << b << ' ';
std::cout << std::endl;
}
std::cout << std::endl;
for ( const auto &a : tablero1 )
{
for ( auto x : a ) std::cout << x << ' ';
std::cout << std::endl;
}
return 0;
}
true false false
false true false
false false true
1 0 0
0 1 0
0 0 1
forloops would do the trick.boolarray? Also why do you need it to be anintarray in the first place?arrayhas no such constructor.