Re: Range checked assignment

2020-09-08 Thread Harry Gillanders via Digitalmars-d-learn
On Tuesday, 8 September 2020 at 14:18:14 UTC, Cecil Ward wrote: What I would like to do is (in pseudo-code) : declare_var my_var : int range 0..7; // i.e. 0 <= val <= 7; my_var = 6; // ok my_var = 8; // bang ! static assert fail or assert fail at runtime my_var = 6;

Re: How to get the element type of an array?

2020-08-24 Thread Harry Gillanders via Digitalmars-d-learn
On Tuesday, 25 August 2020 at 03:41:06 UTC, Jon Degenhardt wrote: What's the best way to get the element type of an array at compile time? Something like std.range.ElementType except that works on any array type. There is std.traits.ForeachType, but it wasn't clear if that was the right

Re: How to use GET_X_LPARAM in D ?

2020-05-21 Thread Harry Gillanders via Digitalmars-d-learn
On Thursday, 21 May 2020 at 18:42:47 UTC, Vinod K Chandran wrote: Hi all, I need to use the macro GET_X_LPARAM. But compiler says that "undefined identifier GET_X_LPARAM". I cant find any modules with GET_X_LPARAM defined. Do i miss something ? GET_X_LPARAM isn't defined in Phobos's Windows

Re: countUntil with negated pre-defined predicate?

2020-05-03 Thread Harry Gillanders via Digitalmars-d-learn
On Sunday, 3 May 2020 at 12:19:30 UTC, Robert M. Münch wrote: I'm doing some cursor-movement in a text-field. So, need to find out where the cursor should be positioned. The Unicode Consortium has some documentation related to segmenting text that you may find useful (notably, section 3):

Re: countUntil with negated pre-defined predicate?

2020-05-02 Thread Harry Gillanders via Digitalmars-d-learn
On Saturday, 2 May 2020 at 18:23:30 UTC, Robert M. Münch wrote: Or is there an even better way to search for all "drawable unicode characters"? This depends on what you classify as drawable, and what you consider to be a character (the joys of Unicode), and why you want to search for them

Re: countUntil with negated pre-defined predicate?

2020-05-02 Thread Harry Gillanders via Digitalmars-d-learn
On Saturday, 2 May 2020 at 18:23:30 UTC, Robert M. Münch wrote: This works: countUntil!(std.uni.isWhite)("hello world")) How can I switch this to (not working); countUntil!(!std.uni.isWhite)("hello world")) without having to write my own predicate? Or is there an even better

Is the behaviour of shift expressions with negative left operands defined / portable?

2020-04-28 Thread Harry Gillanders via Digitalmars-d-learn
The spec doesn't seem to explicitly mention what happens when the left operand of a shift expression is signed and negative. [1] But I know that D follows C's semantics for this sort of stuff, and the C standard specifies that the result of a negative left operand is undefined for `<<`, and

Re: Using the functions "map" and "any" on tuples in compile time.

2020-04-12 Thread Harry Gillanders via Digitalmars-d-learn
On Sunday, 12 April 2020 at 11:17:39 UTC, realhet wrote: Hello, anyone can help me make this better? The functionality I want to achieve is: While serializing the fields of a struct, I want it to check the @STORED UDA on every field. If there is no fields are marked with @STORED, that means