Skip to content

Commit 2d9534c

Browse files
committed
adding == operator to fixed_shape.
1 parent be8fe08 commit 2d9534c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
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...>& lhs, const fixed_shape<X2...>& rhs)
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_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)