digitalmars.D - Struct type value as template parameter
- Tommi (29/29) Jun 12 2012 There seem to be two ways to pass struct type value-parameters to
There seem to be two ways to pass struct type value-parameters to templates, which according to documentation shouldn't be possible. What should I make of this? Should the compiler not allow the following code? (which currently works) struct StructParam { int v; } struct TestStructParam1(T, T param) { immutable(T) p = param; } struct TestStructParam2(alias param) { immutable(StructParam) p = param; } //// Error: arithmetic/string type expected for value-parameter //struct TestStructParam3(StructParam param) //{ // immutable(StructParam) p = param; //} void main(string[] args) { static assert(TestStructParam1!(StructParam, StructParam(42)).p.v == 42); static assert(TestStructParam2!(StructParam(42)).p.v == 42); } Also, is there any intention to allow struct type value-parameters to templates in the future?
Jun 12 2012