void iterate_every_other_element(multi_span<int, dynamic_range> av) { // pick every other element auto length = av.size() / 2; #if _MSC_VER > 1800 auto bounds = strided_bounds<1>({length}, {2}); #else auto bounds = strided_bounds<1>(index<1>{ length }, index<1>{ 2 }); #endif strided_span<int, 1> strided(&av.data()[1], av.size() - 1, bounds); CHECK(strided.size() == length); CHECK(strided.bounds().index_bounds()[0] == length); for (auto i = 0; i < strided.size(); ++i) { CHECK(strided[i] == av[2 * i + 1]); } int idx = 0; for (auto num : strided) { CHECK(num == av[2 * idx + 1]); idx++; } }
namespace { struct BaseClass { }; struct DerivedClass : BaseClass { }; } TEST_CASE("default_constructor") { { multi_span<int> s; CHECK((s.length() == 0 && s.data() == nullptr)); multi_span<const int> cs; CHECK((cs.length() == 0 && cs.data() == nullptr)); } { multi_span<int, 0> s; CHECK((s.length() == 0 && s.data() == nullptr)); multi_span<const int, 0> cs; CHECK((cs.length() == 0 && cs.data() == nullptr)); } { #ifdef CONFIRM_COMPILATION_ERRORS