Answer the question
In order to leave comments, you need to log in
How justified is C++ code in Perl/PHP style with the || in the role of if (!)?
Let's say we have a function
bool tryParseFloat(const wchar_t* aData, const wchar_t aPoint, double& rValue) {}
tryParseFloat(data, L'.', value) || tryParseFloat(data, L',', value);
Answer the question
In order to leave comments, you need to log in
You shouldn't write like that. The optimizer may well precalculate function arguments before calling the methods themselves, and if the arguments are not trivial, then this may change the program logic. And in general, this is quite difficult to read and not obvious.
//! Brief description.
//function try to parse with aPoint decimal delimiter using position order in vector
//in example: if aPoint[0] fails try aPoints[1] etc...
bool tryParseFloat(const wchar_t* aData, const std::vector<wchar_t>& aPoint, float& rValue) {}
tryParseFloat(data, {L'.', L','}, value);
//или
bool tryParseFloat(const wchar_t* aData, const wchar_t* aPoint, float& rValue) {}
tryParseFloat(data, L".,", value);
float tryParseFloat(const wchar_t* aData, const std::vector<wchar_t>& aPoint, bool& result) {}
float tryParseFloat(const wchar_t* aData, const std::vector<wchar_t>& aPoint, float default_value = 0.0f) {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question