Boost logo

Boost :

Subject: [boost] Compile-time autoincrementable values
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2008-12-10 02:31:46

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:

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é.-

Boost list run by bdawes at, gregod at, cpdaniel at, john at