]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Be more pedantic with static_cast (now works also for std::complex). 5509/head
authorLuca Heltai <luca.heltai@sissa.it>
Thu, 23 Nov 2017 08:01:16 +0000 (09:01 +0100)
committerLuca Heltai <luca.heltai@sissa.it>
Thu, 23 Nov 2017 08:01:16 +0000 (09:01 +0100)
tests/tests.h

index 80db3b4a6522bba70f07fec9a04b89208bed752a..84da785348b277828b71000eb47caff653c09c06 100644 (file)
@@ -191,9 +191,10 @@ namespace Testing
 
 // Get a uniformly distributed random value between min and max
 template<typename T=double>
-T random_value(const T &min=0, const T &max=1)
+T random_value(const T &min=static_cast<T>(0),
+               const T &max=static_cast<T>(1))
 {
-  return min+(max-min)*(Testing::rand()/static_cast<T>(RAND_MAX));
+  return min+(max-min)*(static_cast<T>(Testing::rand())/static_cast<T>(RAND_MAX));
 }
 
 

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.