StopWatch

2015-10-20 Thread Shriramana Sharma via Digitalmars-d-learn
http://dlang.org/phobos/std_datetime.html#StopWatch shows the use of TickDuration to measure the time elapsed, but http://dlang.org/phobos/core_time.html#TickDuration says TickDuration is due to be deprecated and MonoTime should be used. It is possible to measure the duration between two

Re: StopWatch

2015-10-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 20, 2015 13:18:12 Shriramana Sharma via Digitalmars-d-learn wrote: > http://dlang.org/phobos/std_datetime.html#StopWatch shows the use of > TickDuration to measure the time elapsed, but > http://dlang.org/phobos/core_time.html#TickDuration says TickDuration is due > to be

Re: kxml - parsing AWS API xml respond

2015-10-20 Thread Kagamin via Digitalmars-d-learn
You can write a helper: XmlNode selectSingleNode(XmlNode src, string path) { XmlNode[] nodes = src.parseXPath(path); return nodes.length==0 ? null : nodes[0]; } Then: string test1 = node.selectSingleNode(`//instanceId`).getCData();

Re: StopWatch

2015-10-20 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-10-20 at 02:19 -0700, Jonathan M Davis via Digitalmars-d- learn wrote: > […] > > auto before = MonoTime.currTime; > // do stuff > auto diff = MonoTime.currTime - before; What import statement do you use to get MonoTime.  I tried the above and got an error with all the things I

Re: StopWatch

2015-10-20 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-10-20 at 15:16 +0100, Russel Winder wrote: > […] > What import statement do you use to get MonoTime.  I tried the above > and got an error with all the things I tried. Hummm… I am now not worried about the import, I tried compiling a different way and it worked. The upshot is that I

std.uni general character category

2015-10-20 Thread Charles Hixson via Digitalmars-d-learn
In std.uni (D Lib 2.068.2) I can no longer see how to get the general category code for a character. Does anyone know what the currently supported way to do that is?

Re: Just one time

2015-10-20 Thread Ali Çehreli via Digitalmars-d-learn
On 10/20/2015 08:48 AM, Andrea Fontana wrote: It happens I need to perform an operation just one time (inside a function, a loop...) An idea that uses a function pointer where the first step does its task and then sets the stage for the following steps: import std.stdio; import std.range;

Re: Just one time

2015-10-20 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 15:55:47 UTC, John Colvin wrote: Be aware that there will be one instance of val per thread, so you are detecting the first run in each thread, not in the program overall. This is the kind of thing I'm interested in. What happens if I call isFirstTime!"test"

Just one time

2015-10-20 Thread Andrea Fontana via Digitalmars-d-learn
It happens I need to perform an operation just one time (inside a function, a loop...) I wonder if doing this it's a good idea or not. bool isFirstTime(alias T)() { static val = true; if (val) { val = false; return true; }

Re: Just one time

2015-10-20 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 15:48:47 UTC, Andrea Fontana wrote: It happens I need to perform an operation just one time (inside a function, a loop...) I wonder if doing this it's a good idea or not. bool isFirstTime(alias T)() { static val = true; if (val) {

Re: Just one time

2015-10-20 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 16:01:58 UTC, Andrea Fontana wrote: On Tuesday, 20 October 2015 at 15:55:47 UTC, John Colvin wrote: Be aware that there will be one instance of val per thread, so you are detecting the first run in each thread, not in the program overall. This is the kind of

Re: kxml - parsing AWS API xml respond

2015-10-20 Thread holo via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 13:23:47 UTC, opticron wrote: I think part of the issue here is that holo isn't quite sure of what information [s]he needs out of the XML reply and how to do that with XPath. The first post mentioned getting instanceId and launchTime, so I'll start there using

Re: Check Instance of Template for Parameter Type/Value

2015-10-20 Thread stew via Digitalmars-d-learn
On Monday, 19 October 2015 at 14:51:29 UTC, Stewart Moth wrote: I'm working with a library that has template structs of mathematical vectors that can sometimes be the type of an array I'm passing to a function. The definition of the struct is like this: struct Vector(type, int dimension_){

Re: kxml - parsing AWS API xml respond

2015-10-20 Thread opticron via Digitalmars-d-learn
I think part of the issue here is that holo isn't quite sure of what information [s]he needs out of the XML reply and how to do that with XPath. The first post mentioned getting instanceId and launchTime, so I'll start there using the AWS example XML found here: