From 3ca1925e1bbabe5e7d95f16b9bd63181e5852067 Mon Sep 17 00:00:00 2001 From: Mykola Vankovych Date: Wed, 7 Apr 2021 21:18:21 +0200 Subject: [PATCH] adding == operator to fixed_shape. --- include/xtensor/xstorage.hpp | 12 ++++++++++++ test/test_xbuilder.cpp | 8 -------- test/test_xreducer.cpp | 8 -------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/include/xtensor/xstorage.hpp b/include/xtensor/xstorage.hpp index 686cb7176..56f7a360a 100644 --- a/include/xtensor/xstorage.hpp +++ b/include/xtensor/xstorage.hpp @@ -1697,6 +1697,18 @@ namespace xt constexpr typename fixed_shape::cast_type fixed_shape::m_array; #endif + template + XTENSOR_FIXED_SHAPE_CONSTEXPR bool operator==(const fixed_shape&, const fixed_shape&) + { + return std::is_same, fixed_shape>::value; + } + + template + XTENSOR_FIXED_SHAPE_CONSTEXPR bool operator!=(const fixed_shape& lhs, const fixed_shape& rhs) + { + return !(lhs == rhs); + } + #undef XTENSOR_FIXED_SHAPE_CONSTEXPR template diff --git a/test/test_xbuilder.cpp b/test/test_xbuilder.cpp index 042e89793..4ce275cb2 100644 --- a/test/test_xbuilder.cpp +++ b/test/test_xbuilder.cpp @@ -361,14 +361,6 @@ namespace xt XT_EXPECT_ANY_THROW(xt::concatenate(xt::xtuple(fa, ta))); } - template - bool operator==(fixed_shape, fixed_shape) - { - std::array ix = {I...}; - std::array jx = {J...}; - return sizeof...(J) == sizeof...(I) && std::equal(ix.begin(), ix.end(), jx.begin()); - } - #ifndef VS_SKIP_CONCATENATE_FIXED // This test mimics the relevant parts of `TEST(xbuilder, concatenate)` TEST(xbuilder, concatenate_fixed) diff --git a/test/test_xreducer.cpp b/test/test_xreducer.cpp index 13081faeb..4e8fd18e6 100644 --- a/test/test_xreducer.cpp +++ b/test/test_xreducer.cpp @@ -939,14 +939,6 @@ namespace xt EXPECT_EQ(b.dimension(), 0u); EXPECT_EQ(minmax(b)(), (A{1.2, 1.2})); } - - template - bool operator==(fixed_shape, fixed_shape) - { - std::array ix = {I...}; - std::array jx = {J...}; - return sizeof...(J) == sizeof...(I) && std::equal(ix.begin(), ix.end(), jx.begin()); - } TEST(xreducer, keep_dims) {