From 0dd5f56bed0362c84819d84ed1a0d77b025ad422 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Mon, 8 Aug 2016 13:33:02 -0700 Subject: [PATCH] Fixed unused variable and ran clang-format. Tested on gcc/clang. --- include/multi_span.h | 6 ++++-- include/span.h | 27 ++++++++++++++++----------- tests/span_tests.cpp | 1 - 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/multi_span.h b/include/multi_span.h index c883fb0..b31909d 100644 --- a/include/multi_span.h +++ b/include/multi_span.h @@ -1066,12 +1066,14 @@ struct dim_t }; template -constexpr std::enable_if_t<(N >= 0),dim_t> dim() noexcept { +constexpr std::enable_if_t<(N >= 0), dim_t> dim() noexcept +{ return dim_t(); } template -constexpr std::enable_if_t> dim(std::ptrdiff_t n) noexcept { +constexpr std::enable_if_t> dim(std::ptrdiff_t n) noexcept +{ return dim_t<>(n); } diff --git a/include/span.h b/include/span.h index ca35d8c..5b2e427 100644 --- a/include/span.h +++ b/include/span.h @@ -171,14 +171,16 @@ namespace details { public: using iterator_category = std::random_access_iterator_tag; - using value_type = std::conditional_t, typename Span::element_type>; + using value_type = + std::conditional_t, + typename Span::element_type>; using difference_type = typename Span::index_type; using pointer = std::add_pointer_t; using reference = std::add_lvalue_reference_t; constexpr span_iterator() : span_iterator(nullptr, 0) noexcept {} - + constexpr span_iterator(const Span* span, typename Span::index_type index) : span_(span), index_(index) { @@ -187,7 +189,9 @@ namespace details friend class span_iterator; constexpr span_iterator(const span_iterator& other) noexcept - : span_iterator(other.span_, other.index_) {} + : span_iterator(other.span_, other.index_) + { + } constexpr reference operator*() const { @@ -248,10 +252,7 @@ namespace details return ret -= n; } - constexpr span_iterator& operator-=(difference_type n) noexcept - { - return *this += -n; - } + constexpr span_iterator& operator-=(difference_type n) noexcept { return *this += -n; } constexpr difference_type operator-(const span_iterator& rhs) const noexcept { @@ -261,12 +262,14 @@ namespace details constexpr reference operator[](difference_type n) const noexcept { return *(*this + n); } - constexpr friend bool operator==(const span_iterator& lhs, const span_iterator& rhs) noexcept + constexpr friend bool operator==(const span_iterator& lhs, + const span_iterator& rhs) noexcept { return lhs.span_ == rhs.span_ && lhs.index_ == rhs.index_; } - constexpr friend bool operator!=(const span_iterator& lhs, const span_iterator& rhs) noexcept + constexpr friend bool operator!=(const span_iterator& lhs, + const span_iterator& rhs) noexcept { return !(lhs == rhs); } @@ -277,7 +280,8 @@ namespace details return lhs.index_ < rhs.index_; } - constexpr friend bool operator<=(const span_iterator& lhs, const span_iterator& rhs) noexcept + constexpr friend bool operator<=(const span_iterator& lhs, + const span_iterator& rhs) noexcept { return !(rhs < lhs); } @@ -287,7 +291,8 @@ namespace details return rhs < lhs; } - constexpr friend bool operator>=(const span_iterator& lhs, const span_iterator& rhs) noexcept + constexpr friend bool operator>=(const span_iterator& lhs, + const span_iterator& rhs) noexcept { return !(rhs > lhs); } diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index 4058463..55610c7 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -831,7 +831,6 @@ SUITE(span_tests) span::iterator it = s.begin(); auto it2 = it + 1; span::const_iterator cit = s.cbegin(); - auto cit2 = s.cbegin(); CHECK(it == cit); CHECK(cit == it);