search for: constructnewvalue

Displaying 4 results from an estimated 4 matches for "constructnewvalue".

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 IRC someone was quite positive that it would become undefined. Anyone that knows for sure (preferably from the language standard, not o...
2008 Jun 05
0
[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(); ... // Use entry --Owen On Jun 5, 2008, at 7:49 AM, Matthijs Kooijman wrote: > Hi All, > > I've been fiddling around with a DenseMap to store cached copies of > some > result. In short, I'm doing the following: > > It = Map.find(Key) > if (It != Map.end() &...
2008 Jun 05
4
[LLVMdev] Adding DenseMap::FindAndConstruct with a default value
Hi All, I've been fiddling around with a DenseMap to store cached copies of some result. In short, I'm doing the following: It = Map.find(Key) if (It != Map.end() && It->second != Unknown) Return It->second; // do_stuff return Map[Key] = Result; However, I this requires two lookups in the hash table, which is not so nice. Currently, there is no way to write this down so
2008 Jun 06
0
[LLVMdev] Adding DenseMap::FindAndConstruct with a default value
..., 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 is undefined. However, Chris > suggested that the default value, ValueT(), is not undefined but simply zero. This is correct; from the standard: "The expression T(), where T is a simple-type-specifier (7.1.5.2) for a non-array complete obje...