chore: Remove catch-all overload of OStaticStream #263
+18
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This an issue because if we attempt to create an custom overloaded operator<< for OStaticStream then it results in ambiguous call compiler error as there are now 2 valid overloads (first is catch-all in toolbox, and 2nd our custom defined one).
The catch-all overload mainly exists to ensure that after several streaming operations, OStaticStream& (ref) is returned. This then allows the OStaticStream& to be implicity converted to a string. For example, consider an expression like so: err_msg() << a << b << c;
If the catch-all overload did not exist, then this expression would return a 'std::ostream&' rather than 'OStaticStream&'. This would prevent the stream from being turned into a string implicitly as std::ostream& is not implicitly convertible to a string_view.
It is only 'err_msg()' that relies on this behaviour. Thus, 'ErrMsg' has now been promoted to a strong type, and implements the functionality it requires rather than burdening a generic type like OStaticStream. And so, the catch-all overload of OStaticStream, as well as implicit conversion to string_view can be removed.
SDB-8506