]> https://gitweb.dealii.org/ - dealii.git/commitdiff
base/tensor.h add two static asserts 9686/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 19 Mar 2020 23:44:00 +0000 (18:44 -0500)
committerMatthias Maier <tamiko@43-1.org>
Fri, 20 Mar 2020 04:21:26 +0000 (23:21 -0500)
Take over Wolfgang's static_assert from pull request #9685

Co-authored-by: Wolfgang Bangerth <bangerth@colostate.edu>
include/deal.II/base/tensor.h

index a45d3ff217d8899a6941f4a4472f5ca0093beef5..3f1844d1f4ee28251384b98910b15b3bd3292ac4 100644 (file)
@@ -93,6 +93,9 @@ template <int dim, typename Number>
 class Tensor<0, dim, Number>
 {
 public:
+  static_assert(dim >= 0,
+                "Tensors must have a dimension greater than or equal to one.");
+
   /**
    * Provide a way to get the dimension of an object without explicit
    * knowledge of it's data type. Implementation is this way instead of
@@ -414,6 +417,10 @@ template <int rank_, int dim, typename Number>
 class Tensor
 {
 public:
+  static_assert(rank_ >= 0,
+                "Tensors must have a rank greater than or equal to one.");
+  static_assert(dim >= 0,
+                "Tensors must have a dimension greater than or equal to one.");
   /**
    * Provide a way to get the dimension of an object without explicit
    * knowledge of it's data type. Implementation is this way instead of

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.