[boost/config] BOOST_LIKELY argument requirements

25 Sep
2014
25 Sep
'14
7:15 a.m.
Looking at the definition of BOOST_LIKELY as #define BOOST_LIKELY(x) __builtin_expect(x, 1) in boost/config/compiler/{clang,intel,gcc}.hpp, and given that at lest the GCC and Clang __builtin_expect has a first parameter of type long, I wonder (1) whether it would be better to define it as #define BOOST_LIKELY(x) __builtin_expect(bool(x), 1) so that
would not fail (effectively changing the requirement for the argument to BOOST_LIKELY from "[the] expression should result in a boolean value" to "it should be contextually convertible to bool"). (2) if not that, whether to at least wrap the expansion of x in parentheses, #define BOOST_LIKELY(x) __builtin_expect((x), 1) Stephan
3827
Age (days ago)
3827
Last active (days ago)
0 comments
1 participants
participants (1)
-
Stephan Bergmann