Compile-time autoincrementable values

Hello everyone, I'm working on a small library to safely work with options made of flags combinations. I'm currently looking for a way to automatically generate contiguous indices, pretty much as an enum does. I was able to achieve this in a very impractical way, which I fear may be based on a compiler bug or an implementation-defined issue. I do not have access to the standard, and I will appreciate if someone with more experience than I could look at the code to confirm my fears. My doubts on standard conformance are mainly - compile time flags: the sizeof a function call expression changes as new overloads (better matches) are added. - sizeof as a default template non-type parameter: (this one really surprised me) when using sizeof as a default parameter it gets reevaluated each time the template is instantiated, so if the sizeof result changes a new type is created.
From there I just built a binary tree of flags, which I use as bits or binary digits. I have implemented it for values of 1, 2 and 3 bits only. The code can be found at the vault at: http://www.boostpro.com/vault/index.php?action=downloadfile&filename=autoincrement.zip&directory=&
Please excuse me for the quality of the code and the description of the method, I'm a college student quite far from being a C++ template expert. Agustín K-ballo Bergé.-

AMDG Agustín K-ballo Bergé wrote:
I'm working on a small library to safely work with options made of flags combinations. I'm currently looking for a way to automatically generate contiguous indices, pretty much as an enum does.
I was able to achieve this in a very impractical way, which I fear may be based on a compiler bug or an implementation-defined issue. I do not have access to the standard, and I will appreciate if someone with more experience than I could look at the code to confirm my fears. My doubts on standard conformance are mainly
- compile time flags: the sizeof a function call expression changes as new overloads (better matches) are added.
Undefined behavior. (14.6.4.2) In Christ, Steven Watanabe
participants (2)
-
Agustín K-ballo Bergé
-
Steven Watanabe