We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 41be223 commit be35a26Copy full SHA for be35a26
3 files changed
include/xtensor/xstorage.hpp
@@ -1692,6 +1692,19 @@ namespace xt
1692
return sizeof...(X) == 0;
1693
}
1694
1695
+ template <std::size_t... Y>
1696
+ XTENSOR_FIXED_SHAPE_CONSTEXPR bool operator==(const fixed_shape<Y...>& b) const {
1697
+ if (size() != b.size()) {
1698
+ return false;
1699
+ }
1700
+ for (std::size_t i = 0; i < size(); ++i) {
1701
+ if ((*this)[i] != b[i]) {
1702
1703
1704
1705
+ return true;
1706
1707
+
1708
private:
1709
1710
XTENSOR_CONSTEXPR_ENHANCED_STATIC cast_type m_array = cast_type({X...});
@@ -1702,6 +1715,7 @@ namespace xt
1715
constexpr typename fixed_shape<X...>::cast_type fixed_shape<X...>::m_array;
1716
#endif
1717
1718
1719
#undef XTENSOR_FIXED_SHAPE_CONSTEXPR
1720
1721
template <class E, std::ptrdiff_t Start, std::ptrdiff_t End = -1>
test/test_xbuilder.cpp
@@ -380,14 +380,6 @@ namespace xt
380
XT_EXPECT_ANY_THROW(xt::concatenate(xt::xtuple(fa, ta)));
381
382
383
- template <std::size_t... I, std::size_t... J>
384
- bool operator==(fixed_shape<I...>, fixed_shape<J...>)
385
- {
386
- std::array<std::size_t, sizeof...(I)> ix = {I...};
387
- std::array<std::size_t, sizeof...(J)> jx = {J...};
388
- return sizeof...(J) == sizeof...(I) && std::equal(ix.begin(), ix.end(), jx.begin());
389
- }
390
-
391
#ifndef VS_SKIP_CONCATENATE_FIXED
392
// This test mimics the relevant parts of `TEST(xbuilder, concatenate)`
393
TEST(xbuilder, concatenate_fixed)
test/test_xstorage.cpp
@@ -207,7 +207,7 @@ namespace xt
207
svector_type e(src);
208
EXPECT_EQ(size_t(10), d.size());
209
EXPECT_EQ(size_t(1), d[2]);
210
211
svector_type f = { 1, 2, 3, 4 };
212
EXPECT_EQ(size_t(4), f.size());
213
EXPECT_EQ(size_t(3), f[2]);
@@ -221,7 +221,7 @@ namespace xt
221
TEST(svector, assign)
222
{
223
svector_type a = { 1, 2, 3, 4 };
224
225
svector_type src1(10, 2);
226
a = src1;
227
EXPECT_EQ(size_t(10), a.size());
@@ -332,7 +332,7 @@ namespace xt
332
EXPECT_EQ(i, a[i]);
333
334
335
336
TEST(fixed_shape, fixed_shape)
337
338
fixed_shape<3, 4, 5> af;
@@ -344,4 +344,14 @@ namespace xt
344
EXPECT_EQ(a.front(), size_t(3));
345
EXPECT_EQ(a.size(), size_t(3));
346
347
348
+ TEST(fixed_shape, operator_eq)
349
+ {
350
+ fixed_shape<2, 3> a, b;
351
+ fixed_shape<5> c;
352
+ fixed_shape<2, 4> d;
353
+ EXPECT_TRUE(a == b);
354
+ EXPECT_FALSE(a == c);
355
+ EXPECT_FALSE(a == d);
356
357
0 commit comments