Re: Getting a range over a const Container

2012-07-19 Thread Artur Skawina
On 07/19/12 06:39, Francisco Soulignac wrote: it's been a while since this question, and I don't know how to solve it either. The following code passes all the test using the last version of dmd (2.059). import std.container, std.algorithm; //non const case void assertequal(T)(SList!(T)

Re: Getting a range over a const Container

2012-07-19 Thread Matthias Walter
On 07/19/2012 06:44 AM, Jonathan M Davis wrote: On Thursday, July 19, 2012 04:39:26 Francisco Soulignac wrote: So, my question is how can I (correctly) traverse a const SList, const DList, etc? Right now? I'm pretty sure that that's impossible. Hopefully that will change, but getting

Re: Magic type return

2012-07-19 Thread Andrea Fontana
Or template inference based on return type like T hello(T)() { static if (is(T ==)) } string v = hello(); Il giorno mer, 18/07/2012 alle 17.38 +0100, Regan Heath ha scritto: On Tue, 17 Jul 2012 15:23:05 +0100, bearophile bearophileh...@lycos.com wrote: Andrea Fontana:

WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
Hello everyone, I had this great idea of writing a Program that intercepts all keyboard presses and modifies them in certain cases. I want to use it as some kind of global makro program to run in the background and for example allow me to easily post unicode smileys. This is where the probelms

~= call copy ctor?

2012-07-19 Thread Namespace
I have a 2 questions. I have this code: [code] import std.stdio; struct Test { public: this(int i = 0) { writeln(Test CTor.); } this(this) { writeln(Test Copy CTor); } ~this() { writeln(Test DTor);

Re: ~= call copy ctor?

2012-07-19 Thread Matthias Walter
On 07/19/2012 02:27 PM, Namespace wrote: I have a 2 questions. I have this code: [code] import std.stdio; struct Test { public: this(int i = 0) { writeln(Test CTor.); } this(this) { writeln(Test Copy CTor); } ~this() {

Re: ~= call copy ctor?

2012-07-19 Thread Namespace
Is there any way to avoid the implizit copy ctor by array concatenation? Or is the only way to use a pointer?

Re: ~= call copy ctor?

2012-07-19 Thread Matthias Walter
On 07/19/2012 03:00 PM, Namespace wrote: Is there any way to avoid the implizit copy ctor by array concatenation? Or is the only way to use a pointer? Yes, in some way you have to. If you want to not copy a lot of data (or avoid additional on-copy effort) you either have to you pointers

Re: ~= call copy ctor?

2012-07-19 Thread Namespace
Ok, so if a put a struct into an array, it will copied into the array. But then? How it is deleted? For exmaple, i have this code: [code] import std.stdio; struct Test { public: static uint _counter; this(int i = 0) { writeln(Test CTor.);

Re: ~= call copy ctor?

2012-07-19 Thread Timon Gehr
Use std.algorithm.move if you want to avoid the copy ctor call.

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread David
Unfortunately there are two versions of this function, SetWindowsHookExW and SetWindowsHookExA. What's the difference? The W-Function is the Unicode version and the A is the ANSI version. Showing the code of your DLL might help.

Re: ~= call copy ctor?

2012-07-19 Thread Namespace
On Thursday, 19 July 2012 at 14:31:02 UTC, Timon Gehr wrote: Use std.algorithm.move if you want to avoid the copy ctor call. With move I see the lost DTor call, but not without. Ist that a bug? o.O

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
But what are the differences of loading the Unicode version vs. the ANSI version? I called the Unicode one because I figured that would be the sensible choice, since Unicode is the default for D (if I remember correctly). I have no clue what the actual effects of calling the wrong version

Re: ~= call copy ctor?

2012-07-19 Thread monarch_dodra
On Thursday, 19 July 2012 at 15:36:01 UTC, Namespace wrote: _counter is still 1 but the scope is released. How is that possible? Even with _arr.clear(); at the end of the scope, _counter is still 1. I see one CTor and one Copy CTor but only one DTor. _arr is actually a dynamic array, which

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
On Thursday, 19 July 2012 at 15:49:48 UTC, DLimited wrote: But what are the differences of loading the Unicode version vs. the ANSI version? I called the Unicode one because I figured that would be the sensible choice, since Unicode is the default for D (if I remember correctly). I have no

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
I guess you have to 'export' the function: extern (Windows) export LRESULT LowLevelKeyboardProc(int code, WPARAM wParam, LPARAM lParam) and include EXPORTS LowLevelKeyboardProc in the .DEF file Thanks, I changed that. Also, I changed LoadLibraryW( ) to LoadLibraryA( ) in the main program

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
On Thursday, 19 July 2012 at 16:38:19 UTC, DLimited wrote: I guess you have to 'export' the function: extern (Windows) export LRESULT LowLevelKeyboardProc(int code, WPARAM wParam, LPARAM lParam) and include EXPORTS LowLevelKeyboardProc in the .DEF file Thanks, I changed that. Also, I

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
You don't see the WHOA message? Try this alias HANDLE HHOOK;

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
On Thursday, 19 July 2012 at 17:35:29 UTC, dnewbie wrote: You don't see the WHOA message? Try this alias HANDLE HHOOK; No, I don't get any message after key-presses. I changed int function() to HANDLE, sadly it still doesn't work.

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
On Thursday, 19 July 2012 at 17:48:06 UTC, DLimited wrote: On Thursday, 19 July 2012 at 17:35:29 UTC, dnewbie wrote: You don't see the WHOA message? Try this alias HANDLE HHOOK; No, I don't get any message after key-presses. I changed int function() to HANDLE, sadly it still doesn't work.

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
On Thursday, 19 July 2012 at 18:40:15 UTC, dnewbie wrote: On Thursday, 19 July 2012 at 17:48:06 UTC, DLimited wrote: On Thursday, 19 July 2012 at 17:35:29 UTC, dnewbie wrote: You don't see the WHOA message? Try this alias HANDLE HHOOK; No, I don't get any message after key-presses. I changed

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
On Thursday, 19 July 2012 at 18:56:15 UTC, DLimited wrote: On Thursday, 19 July 2012 at 18:40:15 UTC, dnewbie wrote: On Thursday, 19 July 2012 at 17:48:06 UTC, DLimited wrote: On Thursday, 19 July 2012 at 17:35:29 UTC, dnewbie wrote: You don't see the WHOA message? Try this alias HANDLE

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
On Thursday, 19 July 2012 at 19:43:45 UTC, dnewbie wrote: On Thursday, 19 July 2012 at 18:56:15 UTC, DLimited wrote: On Thursday, 19 July 2012 at 18:40:15 UTC, dnewbie wrote: On Thursday, 19 July 2012 at 17:48:06 UTC, DLimited wrote: On Thursday, 19 July 2012 at 17:35:29 UTC, dnewbie wrote:

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread dnewbie
On Thursday, 19 July 2012 at 19:51:31 UTC, DLimited wrote: Yes, I did. Are the newlines important? And you really get a MessageBox per keystroke? I start as admin, disabled my AV but still, no success. Yes, I get 2 WHOA messages. One from the WM-KEYDOWN and the other from WM-KEYUP. Sorry I

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread DLimited
On Thursday, 19 July 2012 at 20:06:55 UTC, dnewbie wrote: On Thursday, 19 July 2012 at 19:51:31 UTC, DLimited wrote: Yes, I did. Are the newlines important? And you really get a MessageBox per keystroke? I start as admin, disabled my AV but still, no success. Yes, I get 2 WHOA messages. One

Re: Getting a range over a const Container

2012-07-19 Thread Ellery Newcomer
On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } anyone mind cluing me in on why this is possible?

Re: Getting a range over a const Container

2012-07-19 Thread Ali Çehreli
On 07/19/2012 06:16 PM, Ali Çehreli wrote: On 07/19/2012 06:09 PM, Ellery Newcomer wrote: On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } anyone mind cluing me in on why

Re: Getting a range over a const Container

2012-07-19 Thread Ali Çehreli
On 07/19/2012 06:09 PM, Ellery Newcomer wrote: On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } anyone mind cluing me in on why this is possible? It is the same as in

Re: Getting a range over a const Container

2012-07-19 Thread Ellery Newcomer
On 07/19/2012 06:18 PM, Ali Çehreli wrote: Now the output is different: non-const foo called on a const foo called on b Ali cool beans, thanks.

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread Mike Parker
On 7/20/2012 5:17 AM, DLimited wrote: On Thursday, 19 July 2012 at 20:06:55 UTC, dnewbie wrote: On Thursday, 19 July 2012 at 19:51:31 UTC, DLimited wrote: Yes, I did. Are the newlines important? And you really get a MessageBox per keystroke? I start as admin, disabled my AV but still, no

Re: WinAPI LowLevel Keyboard Hooks

2012-07-19 Thread Mike Parker
On 7/20/2012 12:49 AM, DLimited wrote: But what are the differences of loading the Unicode version vs. the ANSI version? You should always be using the Unicode version of Win32 functions in new applications. AFAIK, the ANSI versions call the Unicode versions internally, but do a conversion