Thread overview
Howto call foreach for void[char[]]
Jul 21, 2005
Burton Radons
Jul 22, 2005
Chris Sauls
July 21, 2005
Howto make this work:

void[char[]] mSupportedMechanisms;

foreach(char[] mech , void b; mSupportedMechanisms){
  /* foo */
}

As you can see, I need a set. I thought "map is a set with pairs, so why not to make void[char[]]". But when comes to using foreach I couldn't find a way to get things working.
-- 
Dawid Ciężarkiewicz
July 21, 2005
Dawid Ciężarkiewicz wrote:

> Howto make this work:
> 
> void[char[]] mSupportedMechanisms;
> 
> foreach(char[] mech , void b; mSupportedMechanisms){
>   /* foo */
> }
> 
> As you can see, I need a set. I thought "map is a set with pairs, so why  not to make void[char[]]". But when comes to using foreach I couldn't find  a way to get things working.

Use .keys:

    foreach(char[] mech; mSupportedMechanisms.keys){
    }

This presently involves an allocation, but the compiler should handle it better in the future.  If you must avoid that, then you'll need to use non-void as the value.
July 22, 2005
Burton Radons wrote:
> This presently involves an allocation, but the compiler should handle it better in the future.  If you must avoid that, then you'll need to use non-void as the value.

Or use 'void[]' or 'void*' as the value.

-- Chris Sauls