mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge pull request #57 from kernhanda/kernhanda/use_algorithms
We should be using standard algorithms where possible.
This commit is contained in:
commit
df88352c1d
@ -28,6 +28,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <algorithm>
|
||||||
#include "fail_fast.h"
|
#include "fail_fast.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -141,12 +142,7 @@ namespace details
|
|||||||
}
|
}
|
||||||
constexpr bool operator==(const ConcreteType& rhs) const noexcept
|
constexpr bool operator==(const ConcreteType& rhs) const noexcept
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < rank; ++i)
|
return std::equal(elems, elems + rank, rhs.elems);
|
||||||
{
|
|
||||||
if (elems[i] != rhs.elems[i])
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
constexpr bool operator!=(const ConcreteType& rhs) const noexcept
|
constexpr bool operator!=(const ConcreteType& rhs) const noexcept
|
||||||
{
|
{
|
||||||
@ -159,8 +155,7 @@ namespace details
|
|||||||
constexpr ConcreteType operator-() const
|
constexpr ConcreteType operator-() const
|
||||||
{
|
{
|
||||||
ConcreteType ret = to_concrete();
|
ConcreteType ret = to_concrete();
|
||||||
for (size_t i = 0; i < rank; ++i)
|
std::transform(ret, ret + rank, ret, std::negate<ValueType>{});
|
||||||
ret.elems[i] = -ret.elems[i];
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
constexpr ConcreteType operator+(const ConcreteType& rhs) const
|
constexpr ConcreteType operator+(const ConcreteType& rhs) const
|
||||||
|
Loading…
Reference in New Issue
Block a user