#include #include #include #ifdef DEBUG_OUTPUT #include #endif int main() { typedef boost::multi_array MA; MA ma(boost::extents[8]); for (size_t i = 0; i < 4; ++i) { ma[i] = i; } MA::const_array_view<1>::type src = ma[boost::indices[MA::index_range(0,4)]]; #ifdef FUDGED_RANGE // This is wrong, but works. MA::array_view<1>::type dst = ma[boost::indices[MA::index_range(7,5,-1)]]; #else // This is correct, but fails. MA::array_view<1>::type dst = ma[boost::indices[MA::index_range(7,3,-1)]]; #endif #ifdef DEBUG_OUTPUT std::cout << "src.shape()[0] = " << src.shape()[0] << std::endl; std::cout << "dst.shape()[0] = " << dst.shape()[0] << std::endl; #endif BOOST_TEST(src.shape()[0] == dst.shape()[0]); dst = src; for (size_t i = 0; i < 4; ++i) { BOOST_TEST(ma[i] == i); BOOST_TEST(ma[i] == ma[7 - i]); } return boost::report_errors(); }