Fixed unused variable and ran clang-format. Tested on gcc/clang.

This commit is contained in:
Neil MacIntosh 2016-08-08 13:33:02 -07:00
parent 82389aa630
commit 0dd5f56bed
3 changed files with 20 additions and 14 deletions

View File

@ -1066,12 +1066,14 @@ struct dim_t<dynamic_range>
}; };
template <std::ptrdiff_t N> template <std::ptrdiff_t N>
constexpr std::enable_if_t<(N >= 0),dim_t<N>> dim() noexcept { constexpr std::enable_if_t<(N >= 0), dim_t<N>> dim() noexcept
{
return dim_t<N>(); return dim_t<N>();
} }
template <std::ptrdiff_t N = dynamic_range> template <std::ptrdiff_t N = dynamic_range>
constexpr std::enable_if_t<N == dynamic_range,dim_t<N>> dim(std::ptrdiff_t n) noexcept { constexpr std::enable_if_t<N == dynamic_range, dim_t<N>> dim(std::ptrdiff_t n) noexcept
{
return dim_t<>(n); return dim_t<>(n);
} }

View File

@ -171,14 +171,16 @@ namespace details
{ {
public: public:
using iterator_category = std::random_access_iterator_tag; using iterator_category = std::random_access_iterator_tag;
using value_type = std::conditional_t<IsConst, std::add_const_t<typename Span::element_type>, typename Span::element_type>; using value_type =
std::conditional_t<IsConst, std::add_const_t<typename Span::element_type>,
typename Span::element_type>;
using difference_type = typename Span::index_type; using difference_type = typename Span::index_type;
using pointer = std::add_pointer_t<value_type>; using pointer = std::add_pointer_t<value_type>;
using reference = std::add_lvalue_reference_t<value_type>; using reference = std::add_lvalue_reference_t<value_type>;
constexpr span_iterator() : span_iterator(nullptr, 0) noexcept {} constexpr span_iterator() : span_iterator(nullptr, 0) noexcept {}
constexpr span_iterator(const Span* span, typename Span::index_type index) constexpr span_iterator(const Span* span, typename Span::index_type index)
: span_(span), index_(index) : span_(span), index_(index)
{ {
@ -187,7 +189,9 @@ namespace details
friend class span_iterator<Span, true>; friend class span_iterator<Span, true>;
constexpr span_iterator(const span_iterator<Span, false>& other) noexcept constexpr span_iterator(const span_iterator<Span, false>& other) noexcept
: span_iterator(other.span_, other.index_) {} : span_iterator(other.span_, other.index_)
{
}
constexpr reference operator*() const constexpr reference operator*() const
{ {
@ -248,10 +252,7 @@ namespace details
return ret -= n; return ret -= n;
} }
constexpr span_iterator& operator-=(difference_type n) noexcept constexpr span_iterator& operator-=(difference_type n) noexcept { return *this += -n; }
{
return *this += -n;
}
constexpr difference_type operator-(const span_iterator& rhs) const noexcept 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 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_; 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); return !(lhs == rhs);
} }
@ -277,7 +280,8 @@ namespace details
return lhs.index_ < rhs.index_; 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); return !(rhs < lhs);
} }
@ -287,7 +291,8 @@ namespace details
return rhs < lhs; 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); return !(rhs > lhs);
} }

View File

@ -831,7 +831,6 @@ SUITE(span_tests)
span<int>::iterator it = s.begin(); span<int>::iterator it = s.begin();
auto it2 = it + 1; auto it2 = it + 1;
span<int>::const_iterator cit = s.cbegin(); span<int>::const_iterator cit = s.cbegin();
auto cit2 = s.cbegin();
CHECK(it == cit); CHECK(it == cit);
CHECK(cit == it); CHECK(cit == it);