default args for templates

Jacob Carlborg doob at me.com
Fri Jan 17 04:41:43 PST 2014


On 2014-01-17 13:18, Manu wrote:
> Observing strange behaviour, just want to know if it's correct...
>
> struct VertexBuffer(VertexDataType = void) {}
>
> VertexBuffer x;
>    Error: struct VertexBuffer(VertexDataType = void) is used as a type
>
> auto y = VertexBuffer();
>    Error: struct VertexBuffer(VertexDataType = void) cannot deduce
> template function from argument types !()()
>
> But this works:
> VertexBuffer!() z;
>
>
> Why should I need to supply an empty argument list? This defeats the
> purpose of the default arg, and obscures my code in the common case.
>
> Untyped vertex buffers are the default, and it would be nice to be able
> to declare them trivially.
>
> Also, those error messages are quite unhelpful.

Yeah, that's a really annoying limitation. I'm wonder if there's a 
bugzilla entry for it.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list