From 76f6f4ff417c8d3adc1bdfac19a484a9a2d03591 Mon Sep 17 00:00:00 2001 From: conrad Date: Fri, 11 Jun 2021 15:31:58 +1000 Subject: [PATCH] warn on unused object access --- include/armadillo_bits/field_bones.hpp | 36 +++++++++++++------------- include/armadillo_bits/field_meat.hpp | 18 +++++++++++++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/include/armadillo_bits/field_bones.hpp b/include/armadillo_bits/field_bones.hpp index 3bf03152..e0ccb456 100644 --- a/include/armadillo_bits/field_bones.hpp +++ b/include/armadillo_bits/field_bones.hpp @@ -86,33 +86,33 @@ class field template inline void copy_size(const field& x); - arma_inline oT& operator[](const uword i); - arma_inline const oT& operator[](const uword i) const; + arma_inline arma_warn_unused oT& operator[](const uword i); + arma_inline arma_warn_unused const oT& operator[](const uword i) const; - arma_inline oT& at(const uword i); - arma_inline const oT& at(const uword i) const; + arma_inline arma_warn_unused oT& at(const uword i); + arma_inline arma_warn_unused const oT& at(const uword i) const; - arma_inline oT& operator()(const uword i); - arma_inline const oT& operator()(const uword i) const; + arma_inline arma_warn_unused oT& operator()(const uword i); + arma_inline arma_warn_unused const oT& operator()(const uword i) const; - arma_inline oT& at(const uword row, const uword col); - arma_inline const oT& at(const uword row, const uword col) const; + arma_inline arma_warn_unused oT& at(const uword row, const uword col); + arma_inline arma_warn_unused const oT& at(const uword row, const uword col) const; - arma_inline oT& at(const uword row, const uword col, const uword slice); - arma_inline const oT& at(const uword row, const uword col, const uword slice) const; + arma_inline arma_warn_unused oT& at(const uword row, const uword col, const uword slice); + arma_inline arma_warn_unused const oT& at(const uword row, const uword col, const uword slice) const; - arma_inline oT& operator()(const uword row, const uword col); - arma_inline const oT& operator()(const uword row, const uword col) const; + arma_inline arma_warn_unused oT& operator()(const uword row, const uword col); + arma_inline arma_warn_unused const oT& operator()(const uword row, const uword col) const; - arma_inline oT& operator()(const uword row, const uword col, const uword slice); - arma_inline const oT& operator()(const uword row, const uword col, const uword slice) const; + arma_inline arma_warn_unused oT& operator()(const uword row, const uword col, const uword slice); + arma_inline arma_warn_unused const oT& operator()(const uword row, const uword col, const uword slice) const; - arma_inline oT& front(); - arma_inline const oT& front() const; + arma_inline arma_warn_unused oT& front(); + arma_inline arma_warn_unused const oT& front() const; - arma_inline oT& back(); - arma_inline const oT& back() const; + arma_inline arma_warn_unused oT& back(); + arma_inline arma_warn_unused const oT& back() const; arma_cold inline field_injector operator<<(const oT& val); diff --git a/include/armadillo_bits/field_meat.hpp b/include/armadillo_bits/field_meat.hpp index 95e53a87..ad9036f0 100644 --- a/include/armadillo_bits/field_meat.hpp +++ b/include/armadillo_bits/field_meat.hpp @@ -470,6 +470,7 @@ field::copy_size(const field& x) //! linear element accessor (treats the field as a vector); no bounds check template arma_inline +arma_warn_unused oT& field::operator[] (const uword i) { @@ -481,6 +482,7 @@ field::operator[] (const uword i) //! linear element accessor (treats the field as a vector); no bounds check template arma_inline +arma_warn_unused const oT& field::operator[] (const uword i) const { @@ -492,6 +494,7 @@ field::operator[] (const uword i) const //! linear element accessor (treats the field as a vector); no bounds check template arma_inline +arma_warn_unused oT& field::at(const uword i) { @@ -503,6 +506,7 @@ field::at(const uword i) //! linear element accessor (treats the field as a vector); no bounds check template arma_inline +arma_warn_unused const oT& field::at(const uword i) const { @@ -514,6 +518,7 @@ field::at(const uword i) const //! linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined template arma_inline +arma_warn_unused oT& field::operator() (const uword i) { @@ -527,6 +532,7 @@ field::operator() (const uword i) //! linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined template arma_inline +arma_warn_unused const oT& field::operator() (const uword i) const { @@ -540,6 +546,7 @@ field::operator() (const uword i) const //! element accessor; bounds checking not done when ARMA_NO_DEBUG is defined template arma_inline +arma_warn_unused oT& field::operator() (const uword in_row, const uword in_col) { @@ -553,6 +560,7 @@ field::operator() (const uword in_row, const uword in_col) //! element accessor; bounds checking not done when ARMA_NO_DEBUG is defined template arma_inline +arma_warn_unused const oT& field::operator() (const uword in_row, const uword in_col) const { @@ -566,6 +574,7 @@ field::operator() (const uword in_row, const uword in_col) const //! element accessor; bounds checking not done when ARMA_NO_DEBUG is defined template arma_inline +arma_warn_unused oT& field::operator() (const uword in_row, const uword in_col, const uword in_slice) { @@ -579,6 +588,7 @@ field::operator() (const uword in_row, const uword in_col, const uword in_sl //! element accessor; bounds checking not done when ARMA_NO_DEBUG is defined template arma_inline +arma_warn_unused const oT& field::operator() (const uword in_row, const uword in_col, const uword in_slice) const { @@ -592,6 +602,7 @@ field::operator() (const uword in_row, const uword in_col, const uword in_sl //! element accessor; no bounds check template arma_inline +arma_warn_unused oT& field::at(const uword in_row, const uword in_col) { @@ -603,6 +614,7 @@ field::at(const uword in_row, const uword in_col) //! element accessor; no bounds check template arma_inline +arma_warn_unused const oT& field::at(const uword in_row, const uword in_col) const { @@ -614,6 +626,7 @@ field::at(const uword in_row, const uword in_col) const //! element accessor; no bounds check template arma_inline +arma_warn_unused oT& field::at(const uword in_row, const uword in_col, const uword in_slice) { @@ -625,6 +638,7 @@ field::at(const uword in_row, const uword in_col, const uword in_slice) //! element accessor; no bounds check template arma_inline +arma_warn_unused const oT& field::at(const uword in_row, const uword in_col, const uword in_slice) const { @@ -635,6 +649,7 @@ field::at(const uword in_row, const uword in_col, const uword in_slice) cons template arma_inline +arma_warn_unused oT& field::front() { @@ -647,6 +662,7 @@ field::front() template arma_inline +arma_warn_unused const oT& field::front() const { @@ -659,6 +675,7 @@ field::front() const template arma_inline +arma_warn_unused oT& field::back() { @@ -671,6 +688,7 @@ field::back() template arma_inline +arma_warn_unused const oT& field::back() const {