@@ -1864,13 +1864,20 @@ namespace xt
18641864
18651865 TEST (xview, drop_on_1dim_array)
18661866 {
1867- const auto my_array = xt::xtensor<double , 1 >({1 , 2 , 3 });
1867+ auto my_array = xt::xtensor<double , 1 >({1 , 2 , 3 });
18681868
1869- xt::view (my_array, xt::drop (1 ));
1870- EXPECT_EQ (my_array, (xt::xtensor<double , 1 >{1 , 3 }));
1869+ // drop(1) creates a view excluding index 1
1870+ auto v1 = xt::view (my_array, xt::drop (1 ));
1871+ EXPECT_EQ (v1, (xt::xtensor<double , 1 >{1 , 3 }));
18711872
1873+ // Assign through the drop view
1874+ xt::view (my_array, xt::drop (1 )) = 0 .;
1875+ EXPECT_EQ (my_array, (xt::xtensor<double , 1 >{0 , 2 , 0 }));
1876+
1877+ // Reset, then test drop with a variable (the original compilation issue)
1878+ my_array = xt::xtensor<double , 1 >({1 , 2 , 3 });
18721879 const size_t index = 1 ;
1873- xt::view (my_array, xt::drop (index));
1874- EXPECT_EQ (my_array , (xt::xtensor<double , 1 >{1 }));
1880+ auto v2 = xt::view (my_array, xt::drop (index));
1881+ EXPECT_EQ (v2 , (xt::xtensor<double , 1 >{1 , 3 }));
18751882 }
18761883}
0 commit comments