Page 8 of 8

User feedback Mr. sitmo's prng

Posted: December 24th, 2013, 10:15 am
by Cuchulainn
QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteI don't get the delegate:See the example again Mon Dec 23, 13 08:36 PMI see.RngDelegate rand = prng.NextDouble;is likestd::function rand = enginine.operator();I though that rand was a float (the return type of the NextDouble member function), but you're passing an engine to BoxMullerII.Nice!There are two issues that are confusing (there are two 'levels'):1. Server code e.g. the Box-Muller that contains a delegate type [std::function rand = engine.operator();]2. Clienct code that must assign the delegate type to a target method [RngDelegate rand = prng.NextDouble;]So the two C++ and C# are exactly the same but numerics in .NET with generic types is a non-starter. So I use double.

User feedback Mr. sitmo's prng

Posted: December 24th, 2013, 10:21 am
by Cuchulainn
Indeed Bingo!Here is another example in the same sphere to emulate STL algos in C# and the delegate idea againpublic delegate bool Condition<T> (T value); // ~ std::function() declaration

User feedback Mr. sitmo's prng

Posted: December 24th, 2013, 10:35 am
by Cuchulainn
QuoteOriginally posted by: outrunah,.. I now see this at the toppublic delegate double RngDelegate();*that's* the generic bitIndeed. And you call it as a function ... As with std::function, all that matters for compatibility is function signature, i.e. input args return type // BTW there is no STL-like stuff in C# (some LINQ but that's another ball game)