From: Jean-Paul Pelteret Date: Fri, 2 Feb 2018 05:51:04 +0000 (+0100) Subject: Add operator assigning a scalar to a Tensor<0>. X-Git-Tag: v9.0.0-rc1~481^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2263ac72b63a99089a3adcd55cde5172c1fce1a8;p=dealii.git Add operator assigning a scalar to a Tensor<0>. --- diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 7dd5ee19e2..3664211322 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -205,6 +205,13 @@ public: template Tensor<0,dim,Number> &operator = (const Tensor<0,dim,OtherNumber> &rhs); + /** + * This operator assigns a scalar to a tensor. This obviously requires + * that the @p OtherNumber type is convertible to @p Number. + */ + template + Tensor<0,dim,Number> &operator = (const OtherNumber &d); + /** * Test for equality of two tensors. */ @@ -797,6 +804,16 @@ Tensor<0,dim,Number> &Tensor<0,dim,Number>::operator = (const Tensor<0,dim,Other } +template +template +inline +Tensor<0,dim,Number> &Tensor<0,dim,Number>::operator = (const OtherNumber &d) +{ + value = internal::NumberType::value(d); + return *this; +} + + template template inline