Changeset View
Changeset View
Standalone View
Standalone View
src/script/script_metrics.h
Show All 12 Lines | struct ScriptExecutionMetrics { | ||||
int nSigChecks = 0; | int nSigChecks = 0; | ||||
ScriptExecutionMetrics() = default; | ScriptExecutionMetrics() = default; | ||||
ScriptExecutionMetrics(int _nSigChecks) : nSigChecks(_nSigChecks) {} | ScriptExecutionMetrics(int _nSigChecks) : nSigChecks(_nSigChecks) {} | ||||
bool operator==(const ScriptExecutionMetrics &rhs) { | bool operator==(const ScriptExecutionMetrics &rhs) { | ||||
return nSigChecks == rhs.nSigChecks; | return nSigChecks == rhs.nSigChecks; | ||||
} | } | ||||
ScriptExecutionMetrics &operator+=(const ScriptExecutionMetrics &rhs) { | |||||
nSigChecks += rhs.nSigChecks; | |||||
return *this; | |||||
} | |||||
deadalnix: You find yourself with that pod/non pod problem once again.
This clearly indicates that you… | |||||
markblundebergAuthorUnsubmitted Done Inline ActionsYeah, effectively I'm using += as shorthand for 'merge' / 'accumulate'. For example if one of the values was a boolean that tracks whether some operation has been executed at least once, then, then this would actually perform |= on said boolean, instead of addition. (I have no idea why such a thing would be useful, but that's the meaning.) markblundeberg: Yeah, effectively I'm using += as shorthand for 'merge' / 'accumulate'.
For example if one of… | |||||
deadalnixUnsubmitted Not Done Inline ActionsYou seem to be telling me that it is the responsibility of the class to manage the semantic of its innards. It therefore follows that this is not the responsibility of the code using it. You have a design problem staring you into the face right now. deadalnix: You seem to be telling me that it is the responsibility of the class to manage the semantic of… | |||||
}; | }; | ||||
#endif // BITCOIN_SCRIPT_SCRIPT_METRICS_H | #endif // BITCOIN_SCRIPT_SCRIPT_METRICS_H |
You find yourself with that pod/non pod problem once again.
This clearly indicates that you are trying to build an abstraction, not to bundle various related data together.
It is somewhat strange that you have a += operator defined, but not a + operator defined. The reverse, why not, if you want to make an immutable struct or something, but this is weird.