libwreport 3.38
options.h
Go to the documentation of this file.
1#ifndef WREPORT_OPTIONS_H
2#define WREPORT_OPTIONS_H
3
4#include <cstdint>
5
23#define WREPORT_OPTIONS_HAS_VAR_CLAMP_DOMAIN_ERRORS
24#define WREPORT_OPTIONS_HAS_VAR_HOOK_DOMAIN_ERRORS
25
26namespace wreport {
27class Var;
28
29namespace options {
30
37extern thread_local bool var_silent_domain_errors;
38
46extern thread_local bool var_clamp_domain_errors;
47
53{
54 virtual ~DomainErrorHook();
55 virtual void handle_domain_error_int(Var& var, int32_t val) = 0;
56 virtual void handle_domain_error_double(Var& var, double val) = 0;
57};
58
66extern thread_local DomainErrorHook* var_hook_domain_errors;
67
83template<typename T, typename T1 = T>
85{
86 T old_value;
87 T& param;
88
89 LocalOverride(T& param, T1 new_value)
90 : old_value(param), param(param)
91 {
92 param = new_value;
93 }
95 {
96 param = old_value;
97 }
98};
99
100template<typename T, typename T1 = T> static inline LocalOverride<T> local_override(T& param, T1 new_value)
101{
102 return LocalOverride<T>(param, new_value);
103}
104
105}
106}
107
108#endif
A physical variable.
Definition: var.h:25
String functions.
Definition: benchmark.h:13
thread_local DomainErrorHook * var_hook_domain_errors
If set, delegate handling domain errors to this object.
Interface for a callback hook system to delegate handling domain errors to the code using wreport.
Definition: options.h:53
Temporarily override a variable while this object is in scope.
Definition: options.h:85