As question states, is there a reason why people use the struct version over the normal conditionals?
An excerpt from the Boost Coding Guidelines for Integral Constant Expressions:
Don't use logical operators in integral constant expressions; use template meta-programming instead.
The header contains a number of workaround templates, that fulfil the role of logical operators, for example instead of:
INTEGRAL_CONSTANT1 || INTEGRAL_CONSTANT2
Use:
::boost::type_traits::ice_or<INTEGRAL_CONSTANT1,INTEGRAL_CONSTANT2>::value
Rationale: A number of compilers (particularly the Borland and Microsoft compilers), tend to not to recognise integral constant expressions involving logical operators as genuine integral constant expressions. The problem generally only shows up when the integral constant expression is nested deep inside template code, and is hard to reproduce and diagnose.
So I'd say never on a compliant compiler. (But if you need to support non-compliant compilers, use it.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With