]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Use declval in decltype expression
authorMatthias Maier <tamiko@43-1.org>
Sat, 12 Sep 2015 06:41:15 +0000 (01:41 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sat, 12 Sep 2015 06:41:15 +0000 (01:41 -0500)
```
decltype(std::declval<T>() * std::declval<U>())
```
is the correct syntax. This does not require that ```T``` and ```U``` have
default constructors...

include/deal.II/base/template_constraints.h

index 28e1f0cb95acb78306fa89157a007691e41eb6b2..3a24b1109388e92067959c10ba8ef04b006e1196 100644 (file)
@@ -20,7 +20,7 @@
 #include <deal.II/base/config.h>
 
 #include <complex>
-
+#include <utility>
 
 DEAL_II_NAMESPACE_OPEN
 
@@ -352,7 +352,7 @@ template <typename T, typename U>
 struct ProductType
 {
 #ifdef DEAL_II_WITH_CXX11
-  typedef decltype(T() * U()) type;
+  typedef decltype(std::declval<T>() * std::declval<U>()) type;
 #endif
 };
 

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.