From: Matthias Maier Date: Thu, 19 Mar 2020 23:44:00 +0000 (-0500) Subject: base/tensor.h add two static asserts X-Git-Tag: v9.2.0-rc1~398^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=814636155e3f097f603a6585664df696299cf013;p=dealii.git base/tensor.h add two static asserts Take over Wolfgang's static_assert from pull request #9685 Co-authored-by: Wolfgang Bangerth --- diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index a45d3ff217..3f1844d1f4 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -93,6 +93,9 @@ template 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 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