back

by refp·11y ago·view on hn ↗
It is part of both, the technique described is not the only way to reach a solution for the given problem (implementing a counter usable in constant-expressions).

In other words; if one sees this as a "bug" in the ISO C++ Standard, the "problem" is a lot deeper than friendly definitions (the technique used in the post).

C++ is a complex language, where many rules touch upon other, and with that it is not surprising that some rules can be bent to allow behavior which was perhaps never intended.

Future posts (probably after part 3) will address the philosophy of the "exploit", other techniques that boil down to doing the same thing, as well as proposed (ISO Standard) wording to "fix" the "problem" - if that is the path being walked.

1 comments
I kind of hope they don't fix it. I could see this being as useful as the Boost Pre-processor Library. In fact I already know of a place where it would be useful. The Template Unit Test library requires (did require?) you to manually number your tests in sequence as template arguments. This const_expr counter could be used to not need to assign the numbers by hand.
Couldn't this also be used to generate seeds or salts or something?