From c4f9b87d96176c32ae609c293816dbbe732f2899 Mon Sep 17 00:00:00 2001 From: Kern Handa Date: Fri, 25 Sep 2015 17:01:29 -0700 Subject: [PATCH] We should be using standard algorithms where possible. Use of algorithms in the STL should be promoted where possible. Also fixed up some whitespace issues. --- include/array_view.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/array_view.h b/include/array_view.h index 26a1641..d8b5cab 100644 --- a/include/array_view.h +++ b/include/array_view.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "fail_fast.h" #ifndef _MSC_VER @@ -142,12 +143,7 @@ namespace details } _CONSTEXPR bool operator==(const ConcreteType& rhs) const _NOEXCEPT { - for (unsigned int i = 0; i < rank; ++i) - { - if (elems[i] != rhs.elems[i]) - return false; - } - return true; + return std::equal(elems, elems + rank, rhs.elems); } _CONSTEXPR bool operator!=(const ConcreteType& rhs) const _NOEXCEPT { @@ -160,8 +156,7 @@ namespace details _CONSTEXPR ConcreteType operator-() const { ConcreteType ret = to_concrete(); - for (unsigned int i = 0; i < rank; ++i) - ret.elems[i] = -ret.elems[i]; + std::transform(ret, ret + rank, ret, std::negate{}); return ret; } _CONSTEXPR ConcreteType operator+(const ConcreteType& rhs) const