Re: Overloading funtion templates.

2017-06-30 Thread Balagopal Komarath via Digitalmars-d-learn
On Friday, 30 June 2017 at 04:51:23 UTC, vit wrote: import std.traits : isCallable; auto foo(alias F, T)(T x) if(isCallable!F)//this line is optional { return F(x); } Thanks. That works.

Re: mysql-native + vibe.d example

2017-06-30 Thread Martin Tschierschke via Digitalmars-d-learn
On Friday, 30 June 2017 at 00:52:28 UTC, crimaniak wrote: Hi! Moving my project from mysql-lited to mysql-native I faced the problem with null pointer error inside of mysql-native: [...] It seems I am doing something wrong so myself-native fails to detect it in isValid(). So I search for

Most convenient way to write a loop with fixed length and no need for the index?

2017-06-30 Thread Martin Tschierschke via Digitalmars-d-learn
What do I have to do, to make this work? iota(number).each!...command_x(a...);command_y(b...);command_z(c..)) ^? how to write the lambda? Similar to the ruby (1..number).each{ commands...} Don't want to write the following, because the index i is not used inside the loop

Re: How to partially apply member functions?

2017-06-30 Thread ct via Digitalmars-d-learn
On Thursday, 29 June 2017 at 14:30:19 UTC, Andrea Fontana wrote: On Thursday, 29 June 2017 at 13:01:10 UTC, ct wrote: I was only able to do it this way: auto on_next_previous = entry_.addOnNextMatch(!(on_next_previous, true)); entry_.addOnPreviousMatch(!(on_next_previous,

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread Luis via Digitalmars-d-learn
On Thursday, 29 June 2017 at 12:00:53 UTC, Simon Bürger wrote: Thanks a lot for your comments. On Wednesday, 28 June 2017 at 23:56:42 UTC, Stefan Koch wrote: [...] This is only happening on CTFE ? Enforcing to use the old 8086 FPU for any float/double operation would give a lot performance

Re: mysql-native + vibe.d example

2017-06-30 Thread tetyys via Digitalmars-d-learn
On Friday, 30 June 2017 at 00:52:28 UTC, crimaniak wrote: Hi! Moving my project from mysql-lited to mysql-native I faced the problem with null pointer error inside of mysql-native: seems like it's already fixed

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread kinke via Digitalmars-d-learn
On Friday, 30 June 2017 at 11:42:39 UTC, Luis wrote: On Thursday, 29 June 2017 at 12:00:53 UTC, Simon Bürger wrote: Thanks a lot for your comments. On Wednesday, 28 June 2017 at 23:56:42 UTC, Stefan Koch wrote: [...] This is only happening on CTFE ? Enforcing to use the old 8086 FPU for

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread kinke via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:21:18 UTC, kinke wrote: CTFE only (incl. parsing of literals). Just make sure you don't happen to call a std.math function only accepting reals; I don't know how many of those are still around. Oh, apparently most still are. There are even some mean overloads

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:29:22 UTC, kinke wrote: On Friday, 30 June 2017 at 16:21:18 UTC, kinke wrote: CTFE only (incl. parsing of literals). Just make sure you don't happen to call a std.math function only accepting reals; I don't know how many of those are still around. Oh, apparently

Re: Get Function Body

2017-06-30 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:38:45 UTC, bauss wrote: Is there a way to retrieve the body of a function as a string? Scenario. I want to pass a function to a mixin template and just mixin the body of the function. Ex. mixin template Foo(alias fun) { void bar() {

Get Function Body

2017-06-30 Thread bauss via Digitalmars-d-learn
Is there a way to retrieve the body of a function as a string? Scenario. I want to pass a function to a mixin template and just mixin the body of the function. Ex. mixin template Foo(alias fun) { void bar() { mixin(getBodyOfFun(fun)); } } I'm aware that I can pass a string

Re: Strange Bug in LDC vs DMD

2017-06-30 Thread Murzistor via Digitalmars-d-learn
On Friday, 30 June 2017 at 12:50:24 UTC, FoxyBrown wrote: The funny thing is, newName is printed wrong so Recompute is effected by the rename. Does LDC use Unicode? Or, maybe, standard library under LDC does not support Unicode - then it is a serious bug. Do you use any non-ASCII symbols?

Re: Strange Bug in LDC vs DMD

2017-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 30, 2017 at 12:50:24PM +, FoxyBrown via Digitalmars-d-learn wrote: > I am using dirEntries to iterate over files to rename them. > > I am renaming them in a loop(will change but added code for testing). > > > In DMD the renaming works but in LDC the renaming fails. It fails in

Re: Strange Bug in LDC vs DMD

2017-06-30 Thread FoxyBrown via Digitalmars-d-learn
On Friday, 30 June 2017 at 15:07:29 UTC, Murzistor wrote: On Friday, 30 June 2017 at 12:50:24 UTC, FoxyBrown wrote: The funny thing is, newName is printed wrong so Recompute is effected by the rename. Does LDC use Unicode? Or, maybe, standard library under LDC does not support Unicode - then

Re: Get Function Body

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:43:33 UTC, Stefan Koch wrote: On Friday, 30 June 2017 at 16:38:45 UTC, bauss wrote: Is there a way to retrieve the body of a function as a string? Scenario. I want to pass a function to a mixin template and just mixin the body of the function. Ex. mixin

Re: Force usage of double (instead of higher precision)

2017-06-30 Thread kinke via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:39:16 UTC, Stefan Koch wrote: On Friday, 30 June 2017 at 16:29:22 UTC, kinke wrote: On Friday, 30 June 2017 at 16:21:18 UTC, kinke wrote: CTFE only (incl. parsing of literals). Just make sure you don't happen to call a std.math function only accepting reals; I

Re: Strange Bug in LDC vs DMD

2017-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 30, 2017 at 07:57:22PM +, FoxyBrown via Digitalmars-d-learn wrote: [...] > The only way this can happen is if the rename command is somehow > feeding back in to the algorithm. Since the problem goes away when I > pre-compute dirEntries, it suggests that dirEntries is being lazily

Re: How to partially apply member functions?

2017-06-30 Thread Ali Çehreli via Digitalmars-d-learn
On 06/30/2017 01:43 AM, ct wrote: > entry_.addOnNextMatch(partial!(, true)); Just to note, member function pointers are delegates in D, which combines the 'this' pointer of the object and a context pointer. Since the object is available at run time, such a delegate cannot be used as a

ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
I'm currently getting garbage data when using ReadProcessMemory to read from another process. This is my definition: BOOL ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead); And I'm reading it like this: if

Re: Strange Bug in LDC vs DMD

2017-06-30 Thread FoxyBrown via Digitalmars-d-learn
On Friday, 30 June 2017 at 20:13:37 UTC, H. S. Teoh wrote: On Fri, Jun 30, 2017 at 07:57:22PM +, FoxyBrown via Digitalmars-d-learn wrote: [...] [...] Um... the docs explicit say that dirEntries is lazy, did you not see that? [...] It is possible that dmd has the same problem but I

Natural Sort optimzation

2017-06-30 Thread FoxyBrown via Digitalmars-d-learn
Spent the last hour trying to get a natural sort. Ended up having to create my own(not sure if it's 100% correct though but works in practice). The Rosetta one is not correct. Here is my implementation, anyone care to perfect it? // Compares the strings a and b numerically, e.g., "04038284"

Re: Strange Bug in LDC vs DMD

2017-06-30 Thread FoxyBrown via Digitalmars-d-learn
On Friday, 30 June 2017 at 17:32:33 UTC, H. S. Teoh wrote: On Fri, Jun 30, 2017 at 12:50:24PM +, FoxyBrown via Digitalmars-d-learn wrote: I am using dirEntries to iterate over files to rename them. I am renaming them in a loop(will change but added code for testing). In DMD the

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread ag0aep6g via Digitalmars-d-learn
On Friday, 30 June 2017 at 20:14:15 UTC, bauss wrote: This is my definition: BOOL ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead); And I'm reading it like this: if (!ReadProcessMemory(process, cast(PCVOID)address,

Re: mysql-native + vibe.d example

2017-06-30 Thread crimaniak via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:18:33 UTC, tetyys wrote: On Friday, 30 June 2017 at 00:52:28 UTC, crimaniak wrote: Hi! Moving my project from mysql-lited to mysql-native I faced the problem with null pointer error inside of mysql-native: seems like it's already fixed

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 21:36:25 UTC, ag0aep6g wrote: On Friday, 30 June 2017 at 20:14:15 UTC, bauss wrote: This is my definition: BOOL ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead); And I'm reading it like this: if

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 23:41:19 UTC, bauss wrote: On Friday, 30 June 2017 at 21:36:25 UTC, ag0aep6g wrote: On Friday, 30 June 2017 at 20:14:15 UTC, bauss wrote: [...] I guess the first cast is necessary when `address` isn't typed as a pointer yet. But the other casts shouldn't be

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 30 June 2017 at 23:53:19 UTC, bauss wrote: I suspect the address is wrong, but it's the static address I picked up from ollydbg, so I'm kinda lost as for how ollydbg can get the correct string and I get the wrong one using same address. You are aware that processes life in

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Friday, 30 June 2017 at 23:56:10 UTC, Stefan Koch wrote: On Friday, 30 June 2017 at 23:53:19 UTC, bauss wrote: I suspect the address is wrong, but it's the static address I picked up from ollydbg, so I'm kinda lost as for how ollydbg can get the correct string and I get the wrong one

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread ag0aep6g via Digitalmars-d-learn
On 07/01/2017 01:41 AM, bauss wrote: string ReadWinString(HANDLE process, DWORD address, size_t stringSize, string defaultValue = "") { if (!process || !address) { return defaultValue; } SIZE_T bytesRead; char[1024] data; if (!ReadProcessMemory(process,

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Saturday, 1 July 2017 at 00:23:36 UTC, ag0aep6g wrote: On 07/01/2017 01:41 AM, bauss wrote: string ReadWinString(HANDLE process, DWORD address, size_t stringSize, string defaultValue = "") { if (!process || !address) { return defaultValue; } SIZE_T bytesRead; char[1024]

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jul 01, 2017 at 02:23:36AM +0200, ag0aep6g via Digitalmars-d-learn wrote: > On 07/01/2017 01:41 AM, bauss wrote: [...] > > stringSize, )) { > > return defaultValue; > >} > > > >auto s = cast(string)data[0 .. stringSize]; > > > >return s ? s : defaultValue; > >

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread ag0aep6g via Digitalmars-d-learn
On 07/01/2017 02:30 AM, bauss wrote: On Saturday, 1 July 2017 at 00:23:36 UTC, ag0aep6g wrote: On 07/01/2017 01:41 AM, bauss wrote: [...] if (!ReadProcessMemory(process, cast(PCVOID)address, cast(PVOID), The second cast still looks suspicious. PVOID is void*, right? Then any

Re: ReadProcessMemory + address from ollydbg

2017-06-30 Thread bauss via Digitalmars-d-learn
On Saturday, 1 July 2017 at 00:40:11 UTC, ag0aep6g wrote: On 07/01/2017 02:30 AM, bauss wrote: On Saturday, 1 July 2017 at 00:23:36 UTC, ag0aep6g wrote: On 07/01/2017 01:41 AM, bauss wrote: [...] if (!ReadProcessMemory(process, cast(PCVOID)address, cast(PVOID), The second cast

Strange Bug in LDC vs DMD

2017-06-30 Thread FoxyBrown via Digitalmars-d-learn
I am using dirEntries to iterate over files to rename them. I am renaming them in a loop(will change but added code for testing). In DMD the renaming works but in LDC the renaming fails. It fails in a way that I can't quite tell and I cannot debug because visual D is not working properly