From: Wolfgang Bangerth Date: Mon, 19 Mar 2018 04:21:39 +0000 (-0600) Subject: Convert an Assert into static_assert. X-Git-Tag: v9.0.0-rc1~314^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6060%2Fhead;p=dealii.git Convert an Assert into static_assert. The TableIndices class had Assert statements in a couple of places that the number of indices in question is a positive number, not zero. Proximally, this led to Coverity complaining that a function called in a noexcept function of Table may in fact throw an exception. The warning is correct, and is most easily worked around by converting the assertion into a static_assert -- which has to hold for the entire class, so that's where I moved it from the affected member functions. --- diff --git a/include/deal.II/base/table_indices.h b/include/deal.II/base/table_indices.h index 52b1be0085..79573a78c4 100644 --- a/include/deal.II/base/table_indices.h +++ b/include/deal.II/base/table_indices.h @@ -43,6 +43,9 @@ template class TableIndices { public: + static_assert (N > 0, + "TableIndices objects need to represent at least one index."); + /** * Default constructor. This constructor sets all indices to zero. @@ -182,8 +185,6 @@ protected: template TableIndices::TableIndices() { - Assert (N > 0, ExcMessage("Cannot create a TableIndices object of size 0")); - for (unsigned int i=0; i::TableIndices(const std::size_t index0, const std::size_t index7, const std::size_t index8) { - Assert (N > 0, ExcMessage("Cannot create a TableIndices object of size 0")); - switch (N) { case 1: