From 7b00172f0073305cd868cecc2d8ab0e716613b39 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Mon, 20 Jun 2016 01:41:49 -0700 Subject: [PATCH] Final sync with D0122R3 version of specification. --- include/span.h | 64 +++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/include/span.h b/include/span.h index 00225ba..e52e14a 100644 --- a/include/span.h +++ b/include/span.h @@ -164,96 +164,96 @@ public: using typename Base::pointer; using typename Base::difference_type; - span_iterator() : span_iterator(nullptr, 0) {} - span_iterator(const Span* span, typename Span::index_type index) : span_(span), index_(index) + constexpr span_iterator() : span_iterator(nullptr, 0) {} + constexpr span_iterator(const Span* span, typename Span::index_type index) : span_(span), index_(index) { Expects(span == nullptr || (index_ >= 0 && index <= span_->length())); } - reference operator*() const { Expects(span_); return (*span_)[index_]; } - pointer operator->() const { Expects(span_); return &((*span_)[index_]); } + constexpr reference operator*() const { Expects(span_); return (*span_)[index_]; } + constexpr pointer operator->() const { Expects(span_); return &((*span_)[index_]); } - span_iterator& operator++() noexcept + constexpr span_iterator& operator++() noexcept { Expects(span_ && index_ >= 0 && index_ < span_->length()); ++index_; return *this; } - span_iterator operator++(int) noexcept + constexpr span_iterator operator++(int) noexcept { auto ret = *this; ++(*this); return ret; } - span_iterator& operator--() noexcept + constexpr span_iterator& operator--() noexcept { Expects(span_ && index > 0 && index_ <= span_->length()); --index_; return *this; } - span_iterator operator--(int) noexcept + constexpr span_iterator operator--(int) noexcept { auto ret = *this; --(*this); return ret; } - span_iterator operator+(difference_type n) const noexcept + constexpr span_iterator operator+(difference_type n) const noexcept { auto ret{*this}; return ret += n; } - span_iterator& operator+=(difference_type n) noexcept + constexpr span_iterator& operator+=(difference_type n) noexcept { index_ += n; Expects(span_ && index_ >= 0 && index_ <= span_->length()); return *this; } - span_iterator operator-(difference_type n) const noexcept + constexpr span_iterator operator-(difference_type n) const noexcept { auto ret{*this}; return ret -= n; } - span_iterator& operator-=(difference_type n) noexcept + constexpr span_iterator& operator-=(difference_type n) noexcept { return *this += -n; } - difference_type operator-(const span_iterator& rhs) const noexcept + constexpr difference_type operator-(const span_iterator& rhs) const noexcept { Expects(span_ == rhs.span_); return index_ - rhs.index_; } - reference operator[](difference_type n) const noexcept + constexpr reference operator[](difference_type n) const noexcept { return *(*this + n); } - bool operator==(const span_iterator& rhs) const noexcept + constexpr bool operator==(const span_iterator& rhs) const noexcept { return span_ == rhs.span_ && index_ == rhs.index_; } - bool operator!=(const span_iterator& rhs) const noexcept { return !(*this == rhs); } + constexpr bool operator!=(const span_iterator& rhs) const noexcept { return !(*this == rhs); } - bool operator<(const span_iterator& rhs) const noexcept + constexpr bool operator<(const span_iterator& rhs) const noexcept { Expects(span_ == rhs.span_); return index_ < rhs.index_; } - bool operator<=(const span_iterator& rhs) const noexcept { return !(rhs < *this); } + constexpr bool operator<=(const span_iterator& rhs) const noexcept { return !(rhs < *this); } - bool operator>(const span_iterator& rhs) const noexcept { return rhs < *this; } + constexpr bool operator>(const span_iterator& rhs) const noexcept { return rhs < *this; } - bool operator>=(const span_iterator& rhs) const noexcept { return !(rhs > *this); } + constexpr bool operator>=(const span_iterator& rhs) const noexcept { return !(rhs > *this); } void swap(span_iterator& rhs) noexcept { @@ -267,14 +267,14 @@ private: }; template -span_iterator operator+(typename span_iterator::difference_type n, +constexpr span_iterator operator+(typename span_iterator::difference_type n, const span_iterator& rhs) noexcept { return rhs + n; } template -span_iterator operator-(typename span_iterator::difference_type n, +constexpr span_iterator operator-(typename span_iterator::difference_type n, const span_iterator& rhs) noexcept { return rhs - n; @@ -313,7 +313,7 @@ public: {} template - constexpr span(element_type(&arr)[N]) + constexpr span(element_type(&arr)[N]) noexcept : storage_(&arr[0], extent_type()) {} @@ -496,7 +496,7 @@ private: { public: template - storage_type(pointer data, OtherExtentType ext) + constexpr storage_type(pointer data, OtherExtentType ext) : ExtentType(ext), data_(data) {} constexpr inline pointer data() const noexcept @@ -512,27 +512,27 @@ private: // [span.comparison], span comparison operators template -constexpr bool operator==(const span& l, const span& r) noexcept +constexpr bool operator==(const span& l, const span& r) { return std::equal(l.begin(), l.end(), r.begin(), r.end()); } template -constexpr bool operator!=(const span& l, const span& r) noexcept +constexpr bool operator!=(const span& l, const span& r) { return !(l == r); } template -constexpr bool operator<(const span& l, const span& r) noexcept +constexpr bool operator<(const span& l, const span& r) { return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end()); } template -constexpr bool operator<=(const span& l, const span& r) noexcept +constexpr bool operator<=(const span& l, const span& r) { return !(l > r); } template -constexpr bool operator>(const span& l, const span& r) noexcept +constexpr bool operator>(const span& l, const span& r) { return r < l; } template -constexpr bool operator>=(const span& l, const span& r) noexcept +constexpr bool operator>=(const span& l, const span& r) { return !(l < r); } @@ -557,11 +557,11 @@ namespace details // [span.objectrep], views of object representation template -constexpr span::value> as_bytes(span s) noexcept +span::value> as_bytes(span s) noexcept { return {reinterpret_cast(s.data()), s.size_bytes()}; } template ::value>> -constexpr span::value> as_writeable_bytes(span s) noexcept +span::value> as_writeable_bytes(span s) noexcept { return {reinterpret_cast(s.data()), s.size_bytes()}; } } // namespace gsl