I think this solves the problem, (except for the fact that there it
may be a more efficient way by swapping element by element).
complete code:
--
#include
namespace std
{
template
void swap(
boost::detail::multi_array::sub_array lhs,
boost::detail::multi_array::sub_array rhs)
{
boost::multi_array tmp = lhs;
lhs = rhs;
rhs = tmp;
}
} // namespace std
#include<iostream>
int main(){
boost::multi_array a;
a.resize( boost::extents[2][2] );
for (int i = 0; i < 2; ++i)
for (int j = 0; j < 2; ++j)
a[i][j] = (i+1)*10 + j+1;
// a[0].swap(a[1]);
std::swap( a[0], a[1] );
for (int i = 0; i < 2; ++i)
{
for (int j = 0; j < 2; ++j)
std::cout << a[i][j] << " ";
std::cout << std::endl;
}
return 0;
}
--