Re: Templated struct doesn't need the parameterized type in return type definitions?

2011-03-09 Thread Nick Treleaven
On Tue, 08 Mar 2011 15:25:27 -0500, Steven Schveighoffer wrote: Hey, wouldn't it be cool if I could add a custom allocator to all classes!?... class Collection(T, alloc = DefaultAllocator!T) { Collection!(T) add(T t) { ...; return this; } // 20 other now subtly incorrect functions

Templated struct doesn't need the parameterized type in return type definitions?

2011-03-08 Thread Andrej Mitrovic
import std.stdio; import std.traits; import std.exception; struct CheckedInt(N) if (isIntegral!N) { private N value; ref CheckedInt opUnary(string op)() if (op == ++) { enforce(value != value.max); ++value; return this; } this(N _value) {

Re: Templated struct doesn't need the parameterized type in return type definitions?

2011-03-08 Thread Steven Schveighoffer
On Tue, 08 Mar 2011 12:06:08 -0500, Andrej Mitrovic n...@none.none wrote: import std.stdio; import std.traits; import std.exception; struct CheckedInt(N) if (isIntegral!N) { private N value; ref CheckedInt opUnary(string op)() if (op == ++) { enforce(value != value.max);

Re: Templated struct doesn't need the parameterized type in return type definitions?

2011-03-08 Thread spir
On 03/08/2011 06:20 PM, Steven Schveighoffer wrote: On Tue, 08 Mar 2011 12:06:08 -0500, Andrej Mitrovic n...@none.none wrote: import std.stdio; import std.traits; import std.exception; struct CheckedInt(N) if (isIntegral!N) { private N value; ref CheckedInt opUnary(string op)() if (op == ++)

Re: Templated struct doesn't need the parameterized type in return type definitions?

2011-03-08 Thread David Nadlinger
On 3/8/11 8:20 PM, spir wrote: […] Yet another syntactic special-case for special cases in the language. In this case, there are even 3 ways to write the same thing: […] I don't quite get how you think this would be a syntactic special case. As Steve pointed out, »class Foo(T) {}« is merely

Re: Templated struct doesn't need the parameterized type in return type definitions?

2011-03-08 Thread Steven Schveighoffer
On Tue, 08 Mar 2011 14:20:40 -0500, spir denis.s...@gmail.com wrote: On 03/08/2011 06:20 PM, Steven Schveighoffer wrote: On Tue, 08 Mar 2011 12:06:08 -0500, Andrej Mitrovic n...@none.none wrote: import std.stdio; import std.traits; import std.exception; struct CheckedInt(N) if

Re: Templated struct doesn't need the parameterized type in return type definitions?

2011-03-08 Thread Andrej Mitrovic
On 3/8/11, Steven Schveighoffer schvei...@yahoo.com wrote: See the problem? Yup. Btw, does auto ref still suffer from any bugs that I should know about? I've heard it had issues.

Re: Templated struct doesn't need the parameterized type in return type definitions?

2011-03-08 Thread Jonathan M Davis
On Tuesday, March 08, 2011 15:31:37 Andrej Mitrovic wrote: On 3/8/11, Steven Schveighoffer schvei...@yahoo.com wrote: See the problem? Yup. Btw, does auto ref still suffer from any bugs that I should know about? I've heard it had issues. I'm not sure that it works correctly with properties