Re: how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
On Sunday, 8 July 2018 at 02:10:12 UTC, Simen Kjærås wrote: Also, you should probably use CommonType!A for the type of temp, since an int can't hold all the possible values of a long or ulong (or even uint), and you'll thus get unexpected results with large numbers. -- Simen I see, thanks,

Re: how to do template constraints with variadic templates ?

2018-07-07 Thread Simen Kjærås via Digitalmars-d-learn
On Sunday, 8 July 2018 at 00:52:41 UTC, Flaze07 wrote: On Sunday, 8 July 2018 at 00:46:13 UTC, Flaze07 wrote: I want to force the variadic templates's type to be of certain types, I thought doing this would work auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) ) { int temp; f

Re: how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
On Sunday, 8 July 2018 at 00:46:13 UTC, Flaze07 wrote: I want to force the variadic templates's type to be of certain types, I thought doing this would work auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) ) { int temp; foreach( t ; a ) { temp += t; } retur

how to do template constraints with variadic templates ?

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
I want to force the variadic templates's type to be of certain types, I thought doing this would work auto sum( A... )( A a ) if( isIntegral!( typeid( a[ 0 ] ) ) ) { int temp; foreach( t ; a ) { temp += t; } return temp; } but it gives out error ( note : I want all the

Re: How to use LLD linker?

2018-07-07 Thread 0xEAB via Digitalmars-d-learn
On Friday, 6 July 2018 at 23:54:35 UTC, SrMordred wrote: Well, since its VS 2017 installer, eventually I hit all the components needed to install it properly. Now its working. Thanks 0xEAB for the tip about the Windows SDK too :) No problem :)

Re: Why is it hard to make Qt bindings?

2018-07-07 Thread MGW via Digitalmars-d-learn
On Thursday, 5 July 2018 at 08:42:39 UTC, drug wrote: There were several attempts to make Qt binding for dlang ... QtE 5 works great on Win32/64, Linux 32/64 and Mac OS x 64. The main difference is that Qt5 uses a set of pre-defined slots and signals rather than creating them using a MOC or c

Re: Outside array bounds

2018-07-07 Thread Timoses via Digitalmars-d-learn
On Saturday, 7 July 2018 at 15:25:51 UTC, vino.B wrote: Hi All, If we replace the statement as args[$ -1] the program works are expected, if we apply the same logic in different approach it does not work, in the below code if we command the first block "if (fnID == "ListFilesNames") {} " t

Re: Outside array bounds

2018-07-07 Thread vino.B via Digitalmars-d-learn
On Saturday, 7 July 2018 at 12:13:21 UTC, Alex wrote: On Saturday, 7 July 2018 at 11:22:38 UTC, Timoses wrote: Aw, got it. So args is actually a tuple type where accessing beyond the defined tuple (T) is invalid? auto a = [1, 2, 4]; // works pragma(msg, typeof(a[3]));

Re: guard clause style static if

2018-07-07 Thread Alex via Digitalmars-d-learn
On Saturday, 7 July 2018 at 12:54:03 UTC, kdevel wrote: On Saturday, 7 July 2018 at 12:46:08 UTC, rikki cattermole wrote: On 08/07/2018 12:40 AM, kdevel wrote: Interesting alternative That was not an alternative. That is what your code was doing. What my original code was supposed to do. Bu

Re: guard clause style static if

2018-07-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/07/2018 12:54 AM, kdevel wrote: On Saturday, 7 July 2018 at 12:46:08 UTC, rikki cattermole wrote: On 08/07/2018 12:40 AM, kdevel wrote: Interesting alternative That was not an alternative. That is what your code was doing. What my original code was supposed to do. But it did not compi

Re: guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 12:46:08 UTC, rikki cattermole wrote: On 08/07/2018 12:40 AM, kdevel wrote: Interesting alternative That was not an alternative. That is what your code was doing. What my original code was supposed to do. But it did not compile. Error: array index [0] is outsi

Re: guard clause style static if

2018-07-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/07/2018 12:40 AM, kdevel wrote: Interesting alternative That was not an alternative. That is what your code was doing.

Re: guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 11:56:40 UTC, rikki cattermole wrote: On 07/07/2018 11:44 PM, kdevel wrote: On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole wrote:    static if (args.length == 0)   return; else {    writeln (args [0]);    return bar (args [1 .. $]

Re: Outside array bounds

2018-07-07 Thread Alex via Digitalmars-d-learn
On Saturday, 7 July 2018 at 11:22:38 UTC, Timoses wrote: Aw, got it. So args is actually a tuple type where accessing beyond the defined tuple (T) is invalid? auto a = [1, 2, 4]; // works pragma(msg, typeof(a[3])); auto t = tuple(3, 4, 5.3); // ERROR: // p

Re: guard clause style static if

2018-07-07 Thread rikki cattermole via Digitalmars-d-learn
On 07/07/2018 11:44 PM, kdevel wrote: On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole wrote:    static if (args.length == 0)   return; else {    writeln (args [0]);    return bar (args [1 .. $]); } That's not guard clause style [1][2]. [1] https://refact

Re: guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
On Saturday, 7 July 2018 at 11:29:35 UTC, rikki cattermole wrote:   static if (args.length == 0) return; else {   writeln (args [0]);   return bar (args [1 .. $]); } That's not guard clause style [1][2]. [1] https://refactoring.com/catalog/replaceNestedConditio

Re: guard clause style static if

2018-07-07 Thread rikki cattermole via Digitalmars-d-learn
On 07/07/2018 11:28 PM, kdevel wrote: It appears not to be possible to use static if in "guard clause style" as in    void bar (T ...) (T args)    {   static if (args.length == 0) return; else {   writeln (args [0]);   return bar (args [1 .. $]); }    }

guard clause style static if

2018-07-07 Thread kdevel via Digitalmars-d-learn
It appears not to be possible to use static if in "guard clause style" as in void bar (T ...) (T args) { static if (args.length == 0) return; writeln (args [0]); return bar (args [1 .. $]); } Is this intended?

Re: Outside array bounds

2018-07-07 Thread Timoses via Digitalmars-d-learn
On Saturday, 7 July 2018 at 08:35:27 UTC, Alex wrote: On Saturday, 7 July 2018 at 08:24:21 UTC, Timoses wrote: Interesting.. Looks like the compiler does some boundschecking during compile time. You could circumvent this: void process(T ...)(string ID, T args) { if (ID == "I1") {

Re: Outside array bounds

2018-07-07 Thread Alex via Digitalmars-d-learn
On Saturday, 7 July 2018 at 08:24:21 UTC, Timoses wrote: Interesting.. Looks like the compiler does some boundschecking during compile time. You could circumvent this: void process(T ...)(string ID, T args) { if (ID == "I1") { writeln(args.length, "\t", args[0]); } static i

Re: Outside array bounds

2018-07-07 Thread Alex via Digitalmars-d-learn
On Saturday, 7 July 2018 at 08:09:51 UTC, vino.B wrote: Hi All, Request you help, on the below code import std.stdio: writeln; void process(T ...)(string ID, T args) { if (ID == "I1") { writeln(args.length, "\t", args[0]); } else if (ID == "I2") { writeln(args.length, "\t", args[1]);} } voi

Re: Outside array bounds

2018-07-07 Thread Flaze07 via Digitalmars-d-learn
On Saturday, 7 July 2018 at 08:09:51 UTC, vino.B wrote: Hi All, Request you help, on the below code import std.stdio: writeln; void process(T ...)(string ID, T args) { if (ID == "I1") { writeln(args.length, "\t", args[0]); } else if (ID == "I2") { writeln(args.length, "\t", args[1]);} } voi

Re: Outside array bounds

2018-07-07 Thread Timoses via Digitalmars-d-learn
On Saturday, 7 July 2018 at 08:09:51 UTC, vino.B wrote: Hi All, Request you help, on the below code import std.stdio: writeln; void process(T ...)(string ID, T args) { if (ID == "I1") { writeln(args.length, "\t", args[0]); } else if (ID == "I2") { writeln(args.length, "\t", args[1]);} } voi

Outside array bounds

2018-07-07 Thread vino.B via Digitalmars-d-learn
Hi All, Request you help, on the below code import std.stdio: writeln; void process(T ...)(string ID, T args) { if (ID == "I1") { writeln(args.length, "\t", args[0]); } else if (ID == "I2") { writeln(args.length, "\t", args[1]);} } void main() { string S1 = "Test1", S2 = "Test2", ID1 = "I1",