Skip to content

Commit 3ca1925

Browse files
committed
adding == operator to fixed_shape.
1 parent be8fe08 commit 3ca1925

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

include/xtensor/xstorage.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,18 @@ namespace xt
16971697
constexpr typename fixed_shape<X...>::cast_type fixed_shape<X...>::m_array;
16981698
#endif
16991699

1700+
template <std::size_t... X1, std::size_t... X2>
1701+
XTENSOR_FIXED_SHAPE_CONSTEXPR bool operator==(const fixed_shape<X1...>&, const fixed_shape<X2...>&)
1702+
{
1703+
return std::is_same<fixed_shape<X1...>, fixed_shape<X2...>>::value;
1704+
}
1705+
1706+
template <std::size_t... X1, std::size_t... X2>
1707+
XTENSOR_FIXED_SHAPE_CONSTEXPR bool operator!=(const fixed_shape<X1...>& lhs, const fixed_shape<X2...>& rhs)
1708+
{
1709+
return !(lhs == rhs);
1710+
}
1711+
17001712
#undef XTENSOR_FIXED_SHAPE_CONSTEXPR
17011713

17021714
template <class E, std::ptrdiff_t Start, std::ptrdiff_t End = -1>

test/test_xbuilder.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,6 @@ namespace xt
361361
XT_EXPECT_ANY_THROW(xt::concatenate(xt::xtuple(fa, ta)));
362362
}
363363

364-
template <std::size_t... I, std::size_t... J>
365-
bool operator==(fixed_shape<I...>, fixed_shape<J...>)
366-
{
367-
std::array<std::size_t, sizeof...(I)> ix = {I...};
368-
std::array<std::size_t, sizeof...(J)> jx = {J...};
369-
return sizeof...(J) == sizeof...(I) && std::equal(ix.begin(), ix.end(), jx.begin());
370-
}
371-
372364
#ifndef VS_SKIP_CONCATENATE_FIXED
373365
// This test mimics the relevant parts of `TEST(xbuilder, concatenate)`
374366
TEST(xbuilder, concatenate_fixed)

test/test_xreducer.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -939,14 +939,6 @@ namespace xt
939939
EXPECT_EQ(b.dimension(), 0u);
940940
EXPECT_EQ(minmax(b)(), (A{1.2, 1.2}));
941941
}
942-
943-
template <std::size_t... I, std::size_t... J>
944-
bool operator==(fixed_shape<I...>, fixed_shape<J...>)
945-
{
946-
std::array<std::size_t, sizeof...(I)> ix = {I...};
947-
std::array<std::size_t, sizeof...(J)> jx = {J...};
948-
return sizeof...(J) == sizeof...(I) && std::equal(ix.begin(), ix.end(), jx.begin());
949-
}
950942

951943
TEST(xreducer, keep_dims)
952944
{

0 commit comments

Comments
 (0)