You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot easily use BOOST_UNLIKELY with boost::system::error_code. Compiler complains
error: cannot convert ‘boost::system::error_code’ to ‘long int’ for argument ‘1’ to ‘long int __builtin_expect(long int, long int)’
[build] if (BOOST_UNLIKELY (ec)) {
[build] ^
To workaround the problem I should use macro like following:
if (BOOST_UNLIKELY (!!ec))
... which looks weird and causes unwanted questions during the code review.
I have to add extra braces:
if (BOOST_UNLIKELY (!!ec))
^ -- here ^ --- and here
... instead of:
ifBOOST_UNLIKELY (ec)
{
}
The text was updated successfully, but these errors were encountered:
To modify the BOOST_LIKELY and BOOST_UNLIKELY macros to handle boost::system::error_code, you can redefine them to ensure compatibility without needing additional braces. Here's the updated version:
This approach uses static_cast<bool>(x) to explicitly cast the condition to a boolean type, making it compatible with boost::system::error_code and similar types. This allows you to use the macros as follows:
// Handle error
}
This change ensures the macros work correctly without needing extra braces.
Could you please modify the
BOOST_LIKELY
andBOOST_UNLIKELY
macros in the following way:BOOST_UNLIKELY
withboost::system::error_code
. Compiler complainsTo workaround the problem I should use macro like following:
... which looks weird and causes unwanted questions during the code review.
... instead of:
The text was updated successfully, but these errors were encountered: