mpi_cpp_tools
basic_tools.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include <cmath>
12 
13 
14 namespace mct
15 {
16 
18 {
19 public:
20  NonnegDouble()
21  {
22  value_ = 0;
23  }
24 
25 
26  NonnegDouble(double value)
27  {
28  if(!std::isnan(value) && value < 0.0)
29  throw std::invalid_argument("expected nonnegative double");
30  value_ = value;
31  }
32 
33  operator double() const
34  {
35  return value_;
36  }
37 
38 private:
39  double value_;
40 };
41 
42 
43 
44 
45 
46 
47 }
Definition: basic_tools.hpp:14
Definition: basic_tools.hpp:17