dReal4
rounding_mode_guard.h
1 #pragma once
2 
3 #include <cfenv>
4 
5 namespace dreal {
6 
8  public:
9  /// Saves the current rounding-mode and switch to @p new_round.
10  explicit RoundingModeGuard(int new_round) : round_mode_{fegetround()} {
11  fesetround(new_round);
12  }
13 
14  /// Deleted Copy-constructor.
15  RoundingModeGuard(const RoundingModeGuard&) = delete;
16 
17  /// Deleted Move-constructor.
19 
20  /// Deleted Copy-assignment.
22 
23  /// Deleted Move-assignment.
25 
26  /// Destructor. Restore the saved rounding-mode.
27  ~RoundingModeGuard() { fesetround(round_mode_); }
28 
29  private:
30  /// Saved rounding-mode at the construction.
31  const int round_mode_{};
32 };
33 } // namespace dreal
RoundingModeGuard & operator=(const RoundingModeGuard &)=delete
Deleted Copy-assignment.
RoundingModeGuard(int new_round)
Saves the current rounding-mode and switch to new_round.
Definition: rounding_mode_guard.h:10
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
~RoundingModeGuard()
Destructor. Restore the saved rounding-mode.
Definition: rounding_mode_guard.h:27
Definition: rounding_mode_guard.h:7