On Thu, Mar 22, 2001 at 07:10:13PM +0100, Lars Gullik Bjønnes wrote:
> |   Notice that the code with bitsets is more clear than this version.
> |   Notice the following line:
> |   char const * tag_name[] = {"tt","sf","bf","it","sl","em"};
> 
> And I dislike this one too.
> 
> You can solve this one by a tostr<PAR_TAG> or a operator<<(ostream &,
> PAR_TAG).

  Ok, I'm learning and I admit that there are better solutions. :-)
  
> template<>
> tostr(PAR_TAG const & pt)
> {
>         switch (pt) {
>         case NONE: return string();
>         case TT: return "tt";
>         case SF: return "sf";
>         ... etc;
> }
> 
> btw. it seems that your tag_open should be changed to list<PAR_TAG>
> tag_open.

  I agree.
  Initially I have done that, I don't remember why I change it though.

> |   If I do it like that I need a map to relate the names to the numbers.
> |   
> |   That was the reason that lead me to use the bitset.
> 
> yes, but bitset is not aimed at solving this problem. It is for
> working with bit representations. And by using it you get no type
> checking on the enum type.

  The the "C++ Programming Language" refers bitset to other uses, such as
having parameters with boolean flags, not only for bit operations.

The advantage of bitset over sets, for small sizes, is that you have an easy
way to find if the element is in the set or not.
That is what is needed where, the implementation with enums just says the same thing.

  This is the (only) point where I disagree with you. Bitsets are apropriate
for this job, IMHO. :-)

> -- 
>       Lgb

-- 
José

Reply via email to