Index: llvm/trunk/include/llvm/ADT/ArrayRef.h =================================================================== --- llvm/trunk/include/llvm/ADT/ArrayRef.h +++ llvm/trunk/include/llvm/ADT/ArrayRef.h @@ -273,6 +273,16 @@ } /// @} + /// @name Comparison operators + /// @{ + + friend bool operator==(ArrayRef LHS, ArrayRef RHS) { + return LHS.equals(RHS); + } + + friend bool operator!=(ArrayRef LHS, ArrayRef RHS) { return !(LHS == RHS); } + + /// @} }; /// MutableArrayRef - Represent a mutable reference to an array (0 or more @@ -510,22 +520,6 @@ return MutableArrayRef(data, length); } - /// @} - /// @name ArrayRef Comparison Operators - /// @{ - - template - inline bool operator==(ArrayRef LHS, ArrayRef RHS) { - return LHS.equals(RHS); - } - - template - inline bool operator!=(ArrayRef LHS, ArrayRef RHS) { - return !(LHS == RHS); - } - - /// @} - // ArrayRefs can be treated like a POD type. template struct isPodLike; template struct isPodLike> { Index: llvm/trunk/unittests/ADT/ArrayRefTest.cpp =================================================================== --- llvm/trunk/unittests/ADT/ArrayRefTest.cpp +++ llvm/trunk/unittests/ADT/ArrayRefTest.cpp @@ -188,6 +188,10 @@ EXPECT_TRUE(AR1b.equals({3, 4, 5, 6})); EXPECT_FALSE(AR1b.equals({2, 3, 4, 5, 6})); EXPECT_FALSE(AR1b.equals({3, 4, 5, 6, 7})); + + SmallVector V1{1, 2, 3, 4, 5, 6, 7, 8}; + EXPECT_EQ(AR1, V1); + EXPECT_EQ(V1, AR1); } TEST(ArrayRefTest, EmptyEquals) {