digitalmars.D.learn - Howto call foreach for void[char[]]
- =?utf-8?B?RGF3aWQgQ2nEmcW8YXJraWV3aWN6?= (10/10) Jul 21 2005 Howto make this work:
- Burton Radons (7/18) Jul 21 2005 Use .keys:
- Chris Sauls (3/6) Jul 21 2005 Or use 'void[]' or 'void*' as the value.
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
Jul 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.
Jul 21 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
Jul 21 2005