]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Convert an Assert into static_assert. 6060/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 19 Mar 2018 04:21:39 +0000 (22:21 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 19 Mar 2018 04:21:39 +0000 (22:21 -0600)
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.

include/deal.II/base/table_indices.h

index 52b1be008555633b3c892b00a0c63052d500798e..79573a78c45f40bb21633f3039c3f61977d74f0f 100644 (file)
@@ -43,6 +43,9 @@ template <int N>
 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 <int N>
 TableIndices<N>::TableIndices()
 {
-  Assert (N > 0, ExcMessage("Cannot create a TableIndices object of size 0"));
-
   for (unsigned int i=0; i<N; ++i)
     indices[i] = 0;
 }
@@ -271,8 +272,6 @@ TableIndices<N>::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:

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.