| Thread overview | |||||
|---|---|---|---|---|---|
|
August 04, 2012 Re: enums and std.traits | ||||
|---|---|---|---|---|
| ||||
On Saturday, August 04, 2012 14:09:29 Jonathan M Davis wrote: > I think that the change to std.traits was a big mistake and will probably file it as a regression, but I thought that I should get other people's thoughts on this. http://d.puremagic.com/issues/show_bug.cgi?id=8508 - Jonathan m Davis | ||||
August 04, 2012 Re: enums and std.traits | ||||
|---|---|---|---|---|
| ||||
On 8/4/12, Jonathan M Davis <jmdavisProg@gmx.com> wrote:
> snip
I agree with you. isSomeString!T predicate failing maybe isn't as serious as "!isSomeString!T" passing and ending up with wrong results. At the very least this should have been discussed about before the change.
And why should a template care whether what's passed is an enum or not? This complicates code by having to write multiple constraints or multiple templates just to handle enums as a special case.
| ||||
August 05, 2012 Re: enums and std.traits | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | Andrej Mitrovic , dans le message (digitalmars.D:174259), a écrit : > On 8/4/12, Jonathan M Davis <jmdavisProg@gmx.com> wrote: >> snip > > I agree with you. isSomeString!T predicate failing maybe isn't as serious as "!isSomeString!T" passing and ending up with wrong results. At the very least this should have been discussed about before the change. > > And why should a template care whether what's passed is an enum or not? This complicates code by having to write multiple constraints or multiple templates just to handle enums as a special case. Someone might want to specialize a template for some kinds of enum. I think the right approach is to try to instanciate a template with the enum type, and, on failure, to try to instanciate the template based on the underlying type. The same as fun(foo) try to call foo with the foo type first, then with something foo implicitely cast to. -- Christophe | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply