On Wed, Aug 17, 2016 at 12:20 PM, Maciej Izak <hnb.c...@gmail.com> wrote:
> > 2016-08-17 16:05 GMT+02:00 silvioprog <silviop...@gmail.com>: > >> I need to find the values using case-insensitive keys (I'm using it in a >> class registry of my app), so unfortunately this bug doesn't let me to use >> TDictionary on FPC yet. :-( > > > There is simple workaround: > > === begin code === > > function EqualityComparison(constref ALeft, ARight: string): Boolean; > begin > Result := LowerCase(ALeft) = LowerCase(ARight); > end; > > procedure ExtendedHasher(constref AValue: string; AHashList: PUInt32); > begin > TDefaultHashFactory.GetHashList(Pointer(AValue), Length(AValue) * > SizeOf(Char), AHashList); > end; > > var > list: TDictionary<string, string>; > begin > list := TDictionary<string, string>.Create(TEqualityCompar > er<string>.Construct(EqualityComparison, ExtendedHasher)); > > === end code === > I changed it to a function: function ExtendedHasher(constref AValue: string): UInt32; begin TDefaultHashFactory.GetHashList(Pointer(AValue), Length(AValue) * SizeOf(Char), @Result); end; because the "Error: Incompatible type for arg no. 2: Got "ExtendedHasher(constref AnsiString;PDWord);", expected "<procedure variable type of function(constref AnsiString):DWord;Register>"". Anyway, thanks for the workaround, it can fix the FPC version of my tests. :-) -- Silvio Clécio
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal