Re: Multiple template alias parameters

2015-05-09 Thread Artur Skawina via Digitalmars-d-learn
On 05/08/15 23:56, Brian Schott via Digitalmars-d-learn wrote: > On Friday, 8 May 2015 at 12:44:31 UTC, Artur Skawina wrote: >> On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: >>> The problem occurs when I want to register multiple modules to scan for >>> functions. The grammar does

Re: Multiple template alias parameters

2015-05-08 Thread anonymous via Digitalmars-d-learn
On Friday, 8 May 2015 at 22:29:28 UTC, Biotronic wrote: Sadly, the ... syntax precludes the use of __LINE__ and __FILE__. :( You can put them in the runtime parameters: void traceVars(alias T, U...)(size_t line = __LINE__, string file = __FILE__) { import std.stdio : writeln; wr

Re: Multiple template alias parameters

2015-05-08 Thread Biotronic via Digitalmars-d-learn
On Friday, 8 May 2015 at 21:56:56 UTC, Brian Schott wrote: Allowing "template Tem(alias Args ...)" syntax would let me trace multiple variables at once. Actually, this already works: void traceVars(alias T, U...)() { import std.stdio : writeln; writeln(T.stringof, ": ", T); static

Re: Multiple template alias parameters

2015-05-08 Thread Brian Schott via Digitalmars-d-learn
On Friday, 8 May 2015 at 12:44:31 UTC, Artur Skawina wrote: On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: The problem occurs when I want to register multiple modules to scan for functions. The grammar does not allow this syntax: ``` template (alias Modules ...) { ... ``` The

Re: Multiple template alias parameters

2015-05-08 Thread Brian Schott via Digitalmars-d-learn
On Friday, 8 May 2015 at 02:03:17 UTC, Rikki Cattermole wrote: Can you not use something like this? Yes. I was getting confused by another problem that I had just worked on before this one.

Re: Multiple template alias parameters

2015-05-08 Thread Artur Skawina via Digitalmars-d-learn
On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: > The problem occurs when I want to register multiple modules to scan for > functions. The grammar does not allow this syntax: > > ``` > template (alias Modules ...) { > ... > ``` The grammar allows omitting the 'alias' keyword. art

Re: Multiple template alias parameters

2015-05-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 8/05/2015 1:53 p.m., Brian Schott wrote: I have some code that automatically wires up control flow based on annotations. Use of this code looks something like this: ``` import some_package.some_module; void main(string[] args) { doMagicStuff!(some_package.some_module)(args); } ``` All of

Multiple template alias parameters

2015-05-07 Thread Brian Schott via Digitalmars-d-learn
I have some code that automatically wires up control flow based on annotations. Use of this code looks something like this: ``` import some_package.some_module; void main(string[] args) { doMagicStuff!(some_package.some_module)(args); } ``` All of this works and everything is happy (Except t

Re: Template alias parameters to local variables

2014-09-17 Thread via Digitalmars-d-learn
On Saturday, 13 September 2014 at 11:34:01 UTC, Marc Schütz wrote: Consider the following code: alias Sink = scope void delegate(const(char)[]); private template generateAliases(int __i, __vars...) { import std.conv : to; static if(__i < __vars.length)

Re: Template alias parameters to local variables

2014-09-14 Thread via Digitalmars-d-learn
On Sunday, 14 September 2014 at 09:29:16 UTC, Kagamin wrote: Doesn't this cause infinite recursion? No, because the inner templates are instantiated with different first template parameters. Even if all template parameters were the same, it would only be a runtime recursion.

Re: Template alias parameters to local variables

2014-09-14 Thread Kagamin via Digitalmars-d-learn
Doesn't this cause infinite recursion?

Template alias parameters to local variables

2014-09-13 Thread via Digitalmars-d-learn
Consider the following code: alias Sink = scope void delegate(const(char)[]); private template generateAliases(int __i, __vars...) { import std.conv : to; static if(__i < __vars.length) enum generateAliases = "alias " ~ __vars[__i].stringof ~ " =

Re: template alias parameters

2011-04-06 Thread Jesse Phillips
enuhtac Wrote: > Hi, > > I'm playing around with template alias parameters. At the moment I'm > considering the following simple code: > > struct A > {}; > > struct B( T ) > { > T t; > }; > > struct C( alias T ) > { >

template alias parameters

2011-04-06 Thread enuhtac
Hi, I'm playing around with template alias parameters. At the moment I'm considering the following simple code: struct A {}; struct B( T ) { T t; }; struct C( alias T ) { T t; }; void main() { B!A a; C!A b; } What exactly is the difference between a and b? Both seem

Re: Comparing template alias parameters

2010-12-13 Thread Simen kjaeraas
Simen kjaeraas wrote: Given an index structure like this: struct Index( alias arr ) if ( is( typeof( arr ) t : U[], U ) ) { private size_t idx; @property pure nothrow size_t get( ) const { return idx; } alias get this; invariant( ) { assert( idx < ar

Comparing template alias parameters

2010-12-10 Thread Simen kjaeraas
Given an index structure like this: struct Index( alias arr ) if ( is( typeof( arr ) t : U[], U ) ) { private size_t idx; @property pure nothrow size_t get( ) const { return idx; } alias get this; invariant( ) { assert( idx < arr.length ); } this( siz