What's a good wat to trunctate a time point

2017-05-05 Thread Dukc via Digitalmars-d-learn
I have a time point, be it SysTime or DateTime, whatever. I want to trunctate it to weeks, eg. I want it to become the first point of time during the week it was representing. What's a good way to do that? Only hacks came to my mind. The solution does not have to be generic, trough I'd prefer

Re: What's a good wat to trunctate a time point

2017-05-05 Thread Biotronic via Digitalmars-d-learn
On Friday, 5 May 2017 at 08:02:15 UTC, Dukc wrote: I have a time point, be it SysTime or DateTime, whatever. I want to trunctate it to weeks, eg. I want it to become the first point of time during the week it was representing. What's a good way to do that? Only hacks came to my mind. The solu

Looking for an equivalent to C++ std::getline in D

2017-05-05 Thread k-five via Digitalmars-d-learn
Hi all. I have a simple command-line program utility in C++ that can rename or remove files, based on regular expression. After finding D that is more fun than C++ is, I want to port the code, but I have problem with this part of it: std::getline( iss, match, delimiter ); std::

Re: What's a good wat to trunctate a time point

2017-05-05 Thread Dukc via Digitalmars-d-learn
On Friday, 5 May 2017 at 09:14:21 UTC, Biotronic wrote: Here's an implementation that supports start of year, month, week, day, hour, minute and second. Works for DateTime and SysTime. Not heavily tested (all tests included): [lots of code] Wow! You might want to create a pr to phobos from

opCall with struct alias this

2017-05-05 Thread Patric Dexheimer via Digitalmars-d-learn
struct Base(T){ static T opCall(Args...)( Args args ){ writeln(args); writeln("opCall"); T t; return t; } } struct Data{ Base!Data b; alias b this; } void main() { // Expected: opCall o

Re: opCall with struct alias this

2017-05-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 May 2017 at 13:05:35 UTC, Patric Dexheimer wrote: static T opCall(Args...)( Args args ){ You should never use static opCall. They are ambiguous with non-static opCall as well as with constructors. It is a buggy mess that should never have been in the language in the first

Re: opCall with struct alias this

2017-05-05 Thread Patric Dexheimer via Digitalmars-d-learn
On Friday, 5 May 2017 at 13:19:03 UTC, Adam D. Ruppe wrote: On Friday, 5 May 2017 at 13:05:35 UTC, Patric Dexheimer wrote: [...] You should never use static opCall. They are ambiguous with non-static opCall as well as with constructors. It is a buggy mess that should never have been in the l

How to declare "abstract" delegates list?

2017-05-05 Thread RedCAT via Digitalmars-d-learn
Hello! Is it possible to create a list of slightly different delegates? For example, there is a class hierarchy: class Base; class DerivedOne : Base; class DerivedTwo : Base; And there are several delegates: void delegate(int, Base); void delegate(int, DerivedOne); void delegate(int, DerivedT

Re: What is this error message telling me?

2017-05-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 11, 2017 8:41:21 AM CEST Jonathan M Davis via Digitalmars- d-learn wrote: > So, this should be reported as a bug in icmp. > > https://issues.dlang.org/ https://issues.dlang.org/show_bug.cgi?id=17372 https://github.com/dlang/phobos/pull/5361 - Jonathan M Davis

Re: Looking for an equivalent to C++ std::getline in D

2017-05-05 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 5 May 2017 at 09:54:03 UTC, k-five wrote: Hi all. I have a simple command-line program utility in C++ that can rename or remove files, based on regular expression. After finding D that is more fun than C++ is, I want to port the code, but I have problem with this part of it:

Trying to understand DIP1000

2017-05-05 Thread Dukc via Digitalmars-d-learn
Walters exciting yesterday talk made me think about dip1000 again. I found out that I do not understand this: Containers that own their data will be able to give access to elements by scope ref. The compiler ensures that the references returned never outlive the container. Therefore, the conta

Re: Trying to understand DIP1000

2017-05-05 Thread Dukc via Digitalmars-d-learn
On Friday, 5 May 2017 at 18:04:32 UTC, Dukc wrote: The compiler is too cunning to let you to leak test[x] out of a function by reference, or take an address of it. Nor you can assing it to another variable, because that means copy semantics. And oh, the identity function won't fool the compil

Re: Trying to understand DIP1000

2017-05-05 Thread Dukc via Digitalmars-d-learn
On Friday, 5 May 2017 at 18:04:32 UTC, Dukc wrote: @safe void killDMan() { auto outer = [RefCountedSlice!int(1)]; foreach(ref fail; outer) { outer = [RefCountedSlice!int(1)]; gcActivationAttempt = new int[3]; fail[0] = 24; } } should be int[] gcActivationAtt

MAKELCID C++ translation

2017-05-05 Thread Mike B Johnson via Digitalmars-d-learn
How to translate something like? #define LCID_ENGLISH MAKELCID(MAKELANGID(0x09, 0x01), SORT_DEFAULT) #define LCID_GERMAN MAKELCID(MAKELANGID(0x07, 0x01), SORT_DEFAULT) D seems to be missing these macros and definitions

Re: MAKELCID C++ translation

2017-05-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 May 2017 at 22:57:50 UTC, Mike B Johnson wrote: D seems to be missing these macros and definitions import core.sys.windows.winnt; then they should work

Re: MAKELCID C++ translation

2017-05-05 Thread Mike B Johnson via Digitalmars-d-learn
On Friday, 5 May 2017 at 23:02:53 UTC, Adam D. Ruppe wrote: On Friday, 5 May 2017 at 22:57:50 UTC, Mike B Johnson wrote: D seems to be missing these macros and definitions import core.sys.windows.winnt; then they should work thanks.

Re: COM Expertise needed: COM Callbacks

2017-05-05 Thread Mike B Johnson via Digitalmars-d-learn
I've modified the code and it seems to call GetTypeInfo but the values passed seem frivolous. The modified code I'm using is below. Maybe we can get this to work? I'm interested in a photoshop interop too. Seems like it should be rather trivial to get to work but things don't add up ;/ m

Re: How to declare "abstract" delegates list?

2017-05-05 Thread bauss via Digitalmars-d-learn
On Friday, 5 May 2017 at 14:20:43 UTC, RedCAT wrote: Hello! Is it possible to create a list of slightly different delegates? For example, there is a class hierarchy: class Base; class DerivedOne : Base; class DerivedTwo : Base; And there are several delegates: void delegate(int, Base); void

Re: How to declare "abstract" delegates list?

2017-05-05 Thread bauss via Digitalmars-d-learn
On Saturday, 6 May 2017 at 06:07:01 UTC, bauss wrote: On Friday, 5 May 2017 at 14:20:43 UTC, RedCAT wrote: [...] I would do something like this: [...] You could also do use alias this to use the delegate instead of the class encapsulating the delegate.