[C++-sig] Re: indexing_v2 status update

Raoul Gough RaoulGough at yahoo.co.uk
Fri Jan 23 11:49:59 CET 2004


Joel de Guzman <joel at boost-consulting.com> writes:

> Raoul Gough wrote:
>> David Abrahams <dave at boost-consulting.com> writes:
>>
>>>Joel de Guzman <joel at boost-consulting.com> writes:
[snip]

>>>>Maybe I ought to write the static bitset thing. I wrote one before.
>>>>I'll see if I can get the prototype. There's one here:
>>>>http://spirit.sourceforge.net/dl_more/Spirit_StaticSet.h
>>>>I'll see if I can make it MPLish.
>>>
>>>It'd be easy to base it on vector_c<unsigned long, ....>
>
> Yep. That's what I'm thinking.
>
>> Something like this would be a good solution! Especially since it is
>> possible to take the complement of a set (handy for saying "all
>> features" or "all features except *this*"). However, it would need to
>> have compile-time determination of set membership. Is this possible?
>
> Yep. Sure!

The only worry I see is the notational (or syntax) issue. How easy
would it be to express the combination of possible values? For
reference again, here is what it looks like with plain bits:

    BOOST_STATIC_CONSTANT(
        unsigned int,
        supported_methods = (
              method_len
            | method_getitem
            | method_getitem_slice

            | detail::unsigned_if<
                  value_traits_type::equality_comparable,
                    method_index
                  | method_contains
                  | method_count
              >::value

            // ...

Which is not really pretty, but I think it is understandable
enough. Considering the following two questions:

1. What are the costs of supporting an effectively unlimited number of
   flags?

2. What is the likelihood that we would ever need more than 32 (there
   are currently 16)?

What I'm thinking is, can we go with the simplest approach that works
now, and switch to a more complex solution if it ever becomes
necessary? Of course, it would be helpful to know what the above code
would look like with a vector_c type solution.

-- 
Raoul Gough.
export LESS='-X'





More information about the Cplusplus-sig mailing list