Re: template parameters :: fix

2021-09-03 Thread Charles Hixson via Digitalmars-d-learn
change:             {    rl.remove(i); to:            {    rl  =  rl.remove(i); -- Javascript is what you use to allow third party programs you don't know anything about and doing you know not what to run on your computer.

Re: template parameters

2021-09-02 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 02, 2021 at 02:28:23PM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] > -- > Javascript is what you use to allow third part programs you don't know > anything about and doing you know not what to run on your computer. ROFL! I'm st^Wborrowing this for my quotes file. ;-)

Re: template parameters

2021-09-02 Thread Charles Hixson via Digitalmars-d-learn
Thanks.  See below for what I did. On 8/29/21 5:05 PM, Ali Çehreli via Digitalmars-d-learn wrote: On 8/29/21 3:31 PM, Charles Hixson wrote: > Thanks.  I going to have to study: > > enum supportsCall = isIntegral!(typeof(T.init.%s())); > > > for awhile to make any sense of that, but it looks like

Re: template parameters

2021-08-29 Thread Ali Çehreli via Digitalmars-d-learn
On 8/29/21 3:31 PM, Charles Hixson wrote: > Thanks. I going to have to study: > > enum supportsCall = isIntegral!(typeof(T.init.%s())); > > > for awhile to make any sense of that, but it looks like just what I was > looking for. Trying to explain with comments: // This is an eponymous template

Re: template parameters

2021-08-29 Thread Charles Hixson via Digitalmars-d-learn
Thanks.  I going to have to study: enum supportsCall = isIntegral!(typeof(T.init.%s())); for awhile to make any sense of that, but it looks like just what I was looking for. On 8/29/21 2:41 PM, Ali Çehreli via Digitalmars-d-learn wrote: On 8/29/21 11:32 AM, Charles H. wrote: I've set up a

Re: template parameters

2021-08-29 Thread Ali Çehreli via Digitalmars-d-learn
On 8/29/21 11:32 AM, Charles H. wrote: I've set up a class template (so far untested) thus:     class    AARL (T, ndx = "ndx")     if (isIntegral(T.init.ndx) )     If I'm correct, this should work for ndx an integer variable of T, but I'd really like T to be able to be anything whic

Re: Template parameters that don't affect template type

2016-08-12 Thread Engine Machine via Digitalmars-d-learn
On Thursday, 11 August 2016 at 20:43:13 UTC, Meta wrote: On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote: [...] It can be done, but you have to be explicit and should think very carefully if this is really a good design. struct X(int defaultSize = 100) { int size;

Re: Template parameters that don't affect template type

2016-08-11 Thread Meta via Digitalmars-d-learn
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote: I have the need, in some cases, to pass static information to a template class but don't want it to affect its type. import std.algorithm, core.stdc.stdlib; struct X(int defaultSize = 100) { int Size; int* p; void foo(i

Re: Template parameters that don't affect template type

2016-08-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/11/16 4:15 PM, Engine Machine wrote: On Thursday, 11 August 2016 at 18:42:51 UTC, Steven Schveighoffer wrote: On 8/11/16 2:11 PM, Engine Machine wrote: I have the need, in some cases, to pass static information to a template class but don't want it to affect its type. import std.algorithm

Re: Template parameters that don't affect template type

2016-08-11 Thread Engine Machine via Digitalmars-d-learn
On Thursday, 11 August 2016 at 18:42:51 UTC, Steven Schveighoffer wrote: On 8/11/16 2:11 PM, Engine Machine wrote: I have the need, in some cases, to pass static information to a template class but don't want it to affect its type. import std.algorithm, core.stdc.stdlib; struct X(int defaultSi

Re: Template parameters that don't affect template type

2016-08-11 Thread Engine Machine via Digitalmars-d-learn
Also, what if we use a class instead of a struct? in this case they are both references to the same thing. I see a problem with reflection though, as one could get the template parameter value and it would wrong on conversion. D takes the easy way out of just preventing complex and potentially

Re: Template parameters that don't affect template type

2016-08-11 Thread Engine Machine via Digitalmars-d-learn
On Thursday, 11 August 2016 at 19:28:47 UTC, Lodovico Giaretta wrote: On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote: [...] If, in your case, it is possible to use one type as the other, then specify it. I mean, implement a templated opAssign that allows you to assign valu

Re: Template parameters that don't affect template type

2016-08-11 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote: [...] If, in your case, it is possible to use one type as the other, then specify it. I mean, implement a templated opAssign that allows you to assign values of one instantiation to values of another. While doing so, remember

Re: Template parameters that don't affect template type

2016-08-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/11/16 2:42 PM, Steven Schveighoffer wrote: On 8/11/16 2:11 PM, Engine Machine wrote: I have the need, in some cases, to pass static information to a template class but don't want it to affect its type. import std.algorithm, core.stdc.stdlib; struct X(int defaultSize = 100) { int Size;

Re: Template parameters that don't affect template type

2016-08-11 Thread Ali Çehreli via Digitalmars-d-learn
On 08/11/2016 11:11 AM, Engine Machine wrote: > I have the need, in some cases, to pass static information to a template > class but don't want it to affect its type. > > import std.algorithm, core.stdc.stdlib; > struct X(int defaultSize = 100) > { >int Size; >int* p; >void foo(int siz

Re: Template parameters that don't affect template type

2016-08-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/11/16 2:11 PM, Engine Machine wrote: I have the need, in some cases, to pass static information to a template class but don't want it to affect its type. import std.algorithm, core.stdc.stdlib; struct X(int defaultSize = 100) { int Size; int* p; void foo(int size) { Size = m

Re: Template parameters that don't affect template type

2016-08-11 Thread sldkf via Digitalmars-d-learn
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote: Is there any way to get D to understand I want do not want a template parameter to be part of the type comparison? No. Use a standard run-time parameter. Your problem can be solved by defining a constructor.

Re: Template parameters that don't affect template type

2016-08-11 Thread Engine Machine via Digitalmars-d-learn
On Thursday, 11 August 2016 at 18:11:30 UTC, Engine Machine wrote: I have the need, in some cases, to pass static information to a template class but don't want it to affect its type. import std.algorithm, core.stdc.stdlib; struct X(int defaultSize = 100) { int Size; int* p; void foo(i

Re: Template Parameters in Struct Member Functions

2015-08-22 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 22 August 2015 at 17:08:36 UTC, Mike Parker wrote: void arrayTest(T, int passing) (T arrayT) { ... } I get 'cannot deduce function from argument types' errors. Specifically stating the type of the function doesn't seem to help: test.arrayTest(float [])(farray, 1); test.arrayTe

Re: Template Parameters in Struct Member Functions

2015-08-22 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 22 August 2015 at 16:49:26 UTC, DarthCthulhu wrote: I'm having difficulty understanding how templates operate as function parameters. Say I have this: struct ArrayTest { void arrayTest(T) (T arrayT) { writeln(arrayT); } } unittest { ArrayTest te

Re: template parameters

2009-09-25 Thread BCS
Hello Ellery, BCS wrote: Hello Ellery, Hello. Today I was looking at the grammar for template value parameters and realized I didn't know what the conditional expression is for in TemplateValueParameter => BasicType Declarator : ConditionalExpression So what does it do? (I assume = Condi

Re: template parameters

2009-09-25 Thread Jarrett Billingsley
On Fri, Sep 25, 2009 at 6:48 PM, Ellery Newcomer wrote: > Christopher Wright wrote: >> Ellery Newcomer wrote: >>> Okay, let me rephrase that: >>> >>> When you have a preceded by a colon in a template value >>> parameter, what are its semantics? Is it the same as a default parameter >>> value? Is

Re: template parameters

2009-09-25 Thread Ellery Newcomer
Christopher Wright wrote: > Ellery Newcomer wrote: >> Okay, let me rephrase that: >> >> When you have a preceded by a colon in a template value >> parameter, what are its semantics? Is it the same as a default parameter >> value? Is it some sort of constraining expression? Is it a vestige? > > vo

Re: template parameters

2009-09-25 Thread Christopher Wright
Ellery Newcomer wrote: Okay, let me rephrase that: When you have a preceded by a colon in a template value parameter, what are its semantics? Is it the same as a default parameter value? Is it some sort of constraining expression? Is it a vestige? void foo(T : int)(T value) { // value

Re: template parameters

2009-09-25 Thread Ellery Newcomer
BCS wrote: > Hello Ellery, > >> Hello. >> >> Today I was looking at the grammar for template value parameters and >> realized I didn't know what the conditional expression is for in >> >> TemplateValueParameter => BasicType Declarator : ConditionalExpression >> >> So what does it do? >> >> (I assu

Re: template parameters

2009-09-25 Thread BCS
Hello Ellery, Hello. Today I was looking at the grammar for template value parameters and realized I didn't know what the conditional expression is for in TemplateValueParameter => BasicType Declarator : ConditionalExpression So what does it do? (I assume = ConditionalExpression is the defau