From: Daniel Arndt Date: Tue, 3 Oct 2017 22:53:11 +0000 (+0200) Subject: Introduce operator== and operator!= for ArrayView X-Git-Tag: v9.0.0-rc1~994^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=912e52afcd07ccf5dc065f9930dcca5c1cb04123;p=dealii.git Introduce operator== and operator!= for ArrayView --- diff --git a/include/deal.II/base/array_view.h b/include/deal.II/base/array_view.h index 0cad1ad043..7086d56d33 100644 --- a/include/deal.II/base/array_view.h +++ b/include/deal.II/base/array_view.h @@ -157,6 +157,35 @@ public: */ ArrayView (std::vector::type> &vector); + /** + * Compare two ArrayView objects of the same type. Two objects are considered + * equal if they have the same size and the same starting pointer. + * This version always compares with the const value_type. + */ + bool operator == (const ArrayView &other_view) const; + + /** + * Compare two ArrayView objects of the same type. Two objects are considered + * equal if they have the same size and the same starting pointer. + * This version always compares with the non-const value_type. + */ + bool operator == + (const ArrayView::type> &other_view) const; + + /** + * Compare two ArrayView objects of the same type. Two objects are considered + * equal if they have the same size and the same starting pointer. + * This version always compares with the const value_type. + */ + bool operator != (const ArrayView &other_view) const; + + /** + * Compare two ArrayView objects of the same type. Two objects are considered + * equal if they have the same size and the same starting pointer. + * This version always comapres with the non-const value_type. + */ + bool operator != + (const ArrayView::type> &other_view) const; /** * Return the size (in elements) of the view of memory this object @@ -285,6 +314,49 @@ ArrayView (std::vector::type> &vector) +template +inline +bool +ArrayView::operator == (const ArrayView &other_view) const +{ + return (other_view.begin() == starting_element) + && (other_view.size() == n_elements); +} + + + +template +inline +bool +ArrayView::operator == +(const ArrayView::type> &other_view) const +{ + return (other_view.begin() == starting_element) + && (other_view.size() == n_elements); +} + + + +template +inline +bool +ArrayView::operator != (const ArrayView &other_view) const +{ + return !(*this == other_view); +} + + + +template +inline +bool +ArrayView::operator != +(const ArrayView::type> &other_view) const +{ + return !(*this == other_view); +} + + template inline