Displaying 4 results from an estimated 4 matches for "findandconstruct".
2008 Jun 05
4
[LLVMdev] Adding DenseMap::FindAndConstruct with a default value
...;
// do_stuff
return Value = Result;
However, I'm using an enum as a map value, so when you do Map[Key] while Key
is not yet in the map, the new value will be unitialized (I can't define a
constructor on an enum, right?).
So, to solve this, I propose adding a second version of
DenseMap::FindAndConstruct, which has an extra argument for the default value.
So, it would do the same thing as the original (return a reference to the
value from the map, adding it if it's not already in), but instead of using
ValueT() as a default value, it would use an argument.
Any objections to adding this? Sugges...
2008 Jun 05
0
[LLVMdev] Adding DenseMap::FindAndConstruct with a default value
...; However, I'm using an enum as a map value, so when you do Map[Key]
> while Key
> is not yet in the map, the new value will be unitialized (I can't
> define a
> constructor on an enum, right?).
>
> So, to solve this, I propose adding a second version of
> DenseMap::FindAndConstruct, which has an extra argument for the
> default value.
> So, it would do the same thing as the original (return a reference
> to the
> value from the map, adding it if it's not already in), but instead
> of using
> ValueT() as a default value, it would use an argument.
&g...
2008 Jun 06
2
[LLVMdev] Adding DenseMap::FindAndConstruct with a default value
> Assuming the default value is not a valid entry in your map (for instance,
> if you're using pointers), you can do:
>
> Foo& entry = DenseMap[Key]
> if (entry == DefaultValue)
> entry = constructNewValue();
The problem here is that the DefaultValue is undefined. However, Chris
suggested that the default value, ValueT(), is not undefined but simply zero.
However, on
2008 Jun 06
0
[LLVMdev] Adding DenseMap::FindAndConstruct with a default value
On Fri, Jun 6, 2008 at 12:27 AM, Matthijs Kooijman <matthijs at stdin.nl> wrote:
>> Assuming the default value is not a valid entry in your map (for instance,
>> if you're using pointers), you can do:
>>
>> Foo& entry = DenseMap[Key]
>> if (entry == DefaultValue)
>> entry = constructNewValue();
> The problem here is that the DefaultValue