cdew / omnithreadlibrary

Automatically exported from code.google.com/p/omnithreadlibrary
0 stars 0 forks source link

latest OtlCommon could not be compiled in D2010 #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Reports 
[DCC Error] OtlCommon.pas(1677): E2015 Operator not applicable to this operand 
type

For: 

function TOmniValue.ToObject<T>: T;
begin
  Result := AsObject as T;
end; { TOmniValue.ToObject<T> }

Original issue reported on code.google.com by pnv82g on 14 Jun 2013 at 7:44

GoogleCodeExporter commented 9 years ago
I have this problem too

Original comment by edwin....@innovationgear.com on 10 Jul 2013 at 12:40

GoogleCodeExporter commented 9 years ago
Does D2010 has constraints ? 
http://docwiki.embarcadero.com/RADStudio/XE4/en/Constraints_in_Generics

If it does - would re-formulation fix the issue ? 

function TOmniValue.ToObject<T: class>: T;
begin
  Result := AsObject as T;
end; { TOmniValue.ToObject<T> }

That would loose the ability to pass interfaces as T, but  for a given functio 
nname that is not a big loss probably.

I wonder, though, how does ti compile in later Delphi. Delphi would not allow 
you 

function Sum<T>(x,y:T):T; 
begin Result := X + Y end;

and "as" operator to me does not seem vastly different from "+" operator...

Original comment by Arioch...@gmail.com on 22 Jul 2013 at 7:33

GoogleCodeExporter commented 9 years ago
Fixed.

Original comment by gabr42 on 13 Oct 2013 at 9:17