Signature conditions
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Feb 10 10:50:24 PST 2012
On Fri, Feb 10, 2012 at 07:36:38PM +0100, David Nadlinger wrote:
> On 2/10/12 7:35 PM, David Nadlinger wrote:
> >class(T) if (__traits(compiles, { std.utf.decode(T.init); } )) { … }
>
> (untested, you might have to return the value from the delegate to
> avoid an expression-without-effect error)
Works for me. Thanks!!
On that note, I discovered that if you want signature constraints on a
derived class, the syntax is unbearably ugly:
class Derived(T)
if (/* conditions */)
: Base
{
...
}
I would have expected the syntax to be like this instead:
class Derived(T) : Base
if (/* conditions */)
{
...
}
But this doesn't compile.
T
--
If Java had true garbage collection, most programs would delete themselves upon execution. -- Robert Sewell
More information about the Digitalmars-d-learn
mailing list