digitalmars.D.learn - mtaching types with static if
- Nicholas Wilson (28/28) Oct 01 2017 struct ArrayAccesssor(alias ptr, alias len) {}
- ag0aep6g (3/37) Oct 01 2017 else static if (is(typeof(Fields[0]) : ArrayAccesssor!(ptr,len),
- Nicholas Wilson (2/4) Oct 01 2017 Ah, so close. Thanks!
struct ArrayAccesssor(alias ptr, alias len) {} char * p; size_t len; ArrayAccesssor!(p,len) aa; template helper(Fields...) { static if (Fields.length == 0) enum helper = ""; else static if (is(typeof(Fields[0]) : ArrayAccesssor!(ptr,len),ptr, len)) //13 { pragma(msg, "ArrayAccesssor"); enum helper = helper!(Fields[1 .. $]); } else { pragma(msg, "else"); enum helper = helper!(Fields[1 .. $]); } } enum f = helper!(aa,len); What is the correct line 13 to make the instansiation of `helper!(aa,len)` print ArrayAccesssor else ? Thanks Nic
Oct 01 2017
On 10/01/2017 09:03 AM, Nicholas Wilson wrote:struct ArrayAccesssor(alias ptr, alias len) {} char * p; size_t len; ArrayAccesssor!(p,len) aa; template helper(Fields...) { static if (Fields.length == 0) enum helper = ""; else static if (is(typeof(Fields[0]) : ArrayAccesssor!(ptr,len),ptr, len)) //13 { pragma(msg, "ArrayAccesssor"); enum helper = helper!(Fields[1 .. $]); } else { pragma(msg, "else"); enum helper = helper!(Fields[1 .. $]); } } enum f = helper!(aa,len); What is the correct line 13 to make the instansiation of `helper!(aa,len)` print ArrayAccesssor else ?else static if (is(typeof(Fields[0]) : ArrayAccesssor!(ptr,len), alias ptr, alias len))
Oct 01 2017
On Sunday, 1 October 2017 at 07:21:57 UTC, ag0aep6g wrote:else static if (is(typeof(Fields[0]) : ArrayAccesssor!(ptr,len), alias ptr, alias len))Ah, so close. Thanks!
Oct 01 2017