libwreport  3.12
options.h
Go to the documentation of this file.
1 #ifndef WREPORT_OPTIONS_H
2 #define WREPORT_OPTIONS_H
3 
20 namespace wreport {
21 namespace options {
22 
29 extern thread_local bool var_silent_domain_errors;
30 
46 template<typename T>
48 {
49  T old_value;
50  T& param;
51 
52  LocalOverride(T& param, const T& new_value)
53  : old_value(param), param(param)
54  {
55  param = new_value;
56  }
57  ~LocalOverride()
58  {
59  param = old_value;
60  }
61 };
62 
63 template<typename T> static inline LocalOverride<T> local_override(T& param, const T& new_value)
64 {
65  return LocalOverride<T>(param, new_value);
66 }
67 
68 }
69 }
70 
71 #endif
Temporarily override a variable while this object is in scope.
Definition: options.h:47
thread_local bool var_silent_domain_errors
Whether domain errors on Var assignments raise exceptions.
String functions.
Definition: benchmark.h:13