]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Avoid temporaries
authorMatthias Maier <tamiko@43-1.org>
Mon, 7 Sep 2015 02:02:51 +0000 (21:02 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 7 Sep 2015 18:36:23 +0000 (13:36 -0500)
include/deal.II/base/tensor.h

index a2a3ba0f8a395b146369a765abfd71299b7637af..d386528603ab40a8495ecf727b308cac409bda04 100644 (file)
@@ -140,7 +140,7 @@ inline
 Tensor<0, dim, typename ProductType<Number, OtherNumber>::type>
 operator+ (const Tensor<0,dim,Number> &p, const Tensor<0,dim,OtherNumber> &q)
 {
-  return static_cast<Number>(p) + static_cast<OtherNumber>(q);
+  return static_cast<const Number &>(p) + static_cast<const OtherNumber &>(q);
 }
 
 
@@ -154,7 +154,7 @@ inline
 Tensor<0, dim, typename ProductType<Number, OtherNumber>::type>
 operator- (const Tensor<0,dim,Number> &p, const Tensor<0,dim,OtherNumber> &q)
 {
-  return static_cast<Number>(p) - static_cast<OtherNumber>(q);
+  return static_cast<const Number &>(p) - static_cast<const OtherNumber &>(q);
 }
 
 
@@ -174,7 +174,7 @@ inline
 typename ProductType<Number, OtherNumber>::type
 operator* (const Tensor<0,dim,Number> &p, const Tensor<0,dim,OtherNumber> &q)
 {
-  return static_cast<Number>(p) * static_cast<OtherNumber>(q);
+  return static_cast<const Number &>(p) * static_cast<const OtherNumber &>(q);
 }
 
 //@}

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.